On Wed, Jun 13, 2001 at 11:58:24AM -0400, David Young wrote:
> I've found that if I post to this PerlAccessHandler, I get no response:
> #------------------------
> package Apache::Redirect;
> 
> use strict;
> use Apache::Constants qw(REDIRECT);
> use CGI ();
> 
> sub handler {
>     my($r) = @_;
> 
>     my $q = new CGI();
>     
>     $r->header_out(Location => "http://www.modperl.com/";);
>     return REDIRECT;
> }
> 
> 1;
> #------------------------
> If I comment out "my $q = new CGI();" then it works fine. Any ideas on what
> is causing this?

Actually, it's apache not letting it redirect on a POST form. I don't know
why commenting out CGI makes any difference, but the HTTP RFC does say that
the behaviour is undefined, for 301/2 on anything other than GET, if you
think about it, this makes sense:
>>>POST url
:
<<<302 Location Moved
<<<Location: newurl
<<<
:

now, what method do I use for newurl, GET/POST? if POST, what is in the
content section ?

The spec says that you shouldn't do it. The fact that browsers tend to
respond to anything with a location header (even 200 OK) as being a redirect
seems broken, and they'll always use GET. This is why you've probably
"noticed it working", in reality it's bogus.

Apache enforces it for you.

My advice is to find some other way of doing it.
A "Refresh: 0; URL=newurl" header might do the trick, although you'll need
to make sure you have it in headers_err, because otherwise it won't get
sent as a header.

MBM

Reply via email to