You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Doug MacEachern <do...@pobox.com> on 2000/02/17 00:51:23 UTC

Re: Where did the POST data go in the ErrorDocument request?

On Sun, 30 Jan 2000, Roberto Bourgonjen wrote:

> Hi,
> 
> I redirect 403 requests and create the requested document on the fly. It
> works for GET requests, but if the request is POST, either apache or
> mod_perl transformes it to GET, and the POST data is gone, even if I
> access the $r->prev object.
> 
> I tried fetching the post data even in the uri translation stage, and
> transforming the request into GET (with $r->method('GET')) after storing
> the post data in an environment variable but then apache hangs, probably
> trying to read post data that's no longer there.
> 
> Why is it gone, and where did it go?

this has been explained many times, you can only read POST data once.
if you need to read it more than once, you need to save it somewhere.
a transparent way to do this is to switch the request method from POST to
GET and store the post data in the query string:

package Apache::POST2GET;

use Apache::Constants qw(M_GET);

sub handler {
    my $r = shift;
    if ($r->method eq 'POST') { 
       my $content = $r->content;
       $r->args($content);
       $r->method('GET');
       $r->method_number(M_GET);
       $r->headers_in->unset('Content-length');
    }
}

__END__

#httpd.conf

PerlInitHandler Apache::POST2GET