You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2003/03/02 07:26:54 UTC

Re: [mp2] PerlPostReadRequestHandler and invalid URI

Nick Tonkin wrote:
> Hi,
> 
> I have a handler I call as a PerlPostReadRequestHandler
> 
> sub handler {
> 
>     my $r = shift;
>     my $uri = APR::URI->parse($r->pool, $r->construct_url);
> 
>     $uri->scheme('http');
>     $uri->port('8080');
> 
>     $r->uri($uri->unparse());
> 
>     return Apache::DECLINED;
> }
> 1;
> 
> 
> This consistently leads to an error in the error log:
> 
> Invalid URI in request GET /foo/bar.html
> 
> Even though the request looks good in the access log:
> 
> 400 GET http://www.ladyraquel.com:8080/charters/index.html
> 
> 
> Have I missed soemthing obvious as usual?

Yup, it's not supposed to work. It fails the same way with Apache 1.3. It's 
Apache that asserts, not mod_perl. It expects the $r->uri to start from / at 
this phase, after the mapping phase is completed you can change it any way you 
want.

Here is quick test I've run over mp1:

<Perl>
package Foo2;
use Apache::URI;
use Apache::Constants;
sub handler {
     my $r = shift;
     $r->uri(Apache::URI->parse($r->uri)->unparse);
     warn "uri ", $r->uri, "\n";
     return Apache::Constants::DECLINED;
}
package main;
</Perl>
PerlPostReadRequestHandler Foo2::handler

uri http://localhost:8000/perl/test.pl
[Sun Mar  2 17:22:03 2003] [error] [client 127.0.0.1] Invalid URI in request 
GET /perl/test.pl HTTP/1.0


> PS Stas: I tried for >2hrs to make a test work in the Test framework ...
> it indeed dies with the same error but I wasn't confident that it was
> getting called as an init handler as I wanted ... I couldn't decipher :)

you should have looked at the relevant config section in t/conf/httpd.conf 
(after running t/TEST -conf). I suppose you have added, something like:

__END__
PerlPostReadRequestHandler TestAPI::uri::postreadrequest_handler

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org