"Eric J. Hansen" <[EMAIL PROTECTED]> writes:

> I'm having a problem whereby I can't access POST CGI variables when using
> an output filter (PerlOutputFilterHandler) alongside mod_proxy.
> Parameters on the URL (GET) work just fine, its just the POST variables
> that are missing.
> 
> My setup is that I'm using a mod_proxy reverse proxy to fetch some remote
> content, then doing some analysis on the content using an output filter.

The problem is likely that the apreq filter has not been added to 
the input filter chain in time to read the POST data.

There are two solutions to this problem:

  1) Write a filter init handler for you filter that instantiates an
     Apache::Request object.  See

    http://perl.apache.org/docs/2.0/api/Apache/Filter.html#C_FilterInitHandler_

  2) Use .htaccess or your server config to ensure the apreq input filter
     is active for this request with "AddInputFilter APREQ" or somesuch.

I recommend using (1), and falling back to (2) until you get (1) working.

> I suspect this has something to do with mod_proxy consuming the
> request data - i.e., once the data of the HTTP request is read, its gone.... 

Correct.

[...]

> sub handler   {               # (filter)
>       my $f = shift;
>       my $r = $f->r;
> 
>       if ( ! $r->notes('not_first_bucket') ) {
>               $r->notes->set('not_first_bucket' => 1);
> 
>               my $ApReq = Apache::Request->new($r);
>               my $CgiArgsRef = $ApReq->param;
> 
>               # log CGI variables for debug...
>               $CgiArgsRef->do( sub {
>                       $r->log_error("CGI parameter: '" . $_[0] . 
>                                                "' = '" . $_[1] . "'"); 
>                       return 1;
>               });
>       )
> 
>       return Apache::DECLINED;
> }
> 
> And if I install this as an INPUT filter, 
                              ^^^^^

Danger, Will Robinson!  Generally speaking, you should *not* use 
Apache::Request::param inside an input filter.  Otherwise you run 
the very real risk of an infinite recursion error.  The apreq 
filter will always insert itself as the very *last* input filter in 
the chain, which means it'll call *your* input filter in order to 
get at the requested POST data.  It looks like you managed to carefully
avoid the infinite recursion in your example, but I'm not sure the 
underlying Apache::DECLINED perl magic is smart enough to handle the 
reentry-  thus the 502.

-- 
Joe Schaefer


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to