On Tuesday 19 January 2010 17:11:03 Ivory wrote: > I would like to add args to a request on the fly thanks to an InputFilter. > > It seems like the $f->r->args($new_args) doesn't record the new argument > inside the request. > > For example : > > Inside the filter : > sub handler{ > > my ($f, $bb, $mode, $block, $readbytes) = @_; # filter args # $mode, > $block, $readbytes are passed only for input filters > > my $rv = $f->next->get_brigade($bb, $mode, $block, $readbytes); > return $rv unless $rv == APR::Const::SUCCESS; > > print STDOUT "Perlfilter : Uri = ", $f->r->uri(),"\n"; > print STDOUT $f->r->args(),"\n"; #No argument > $f->r->args("userId=10"); > print STDOUT $f->r->args(),"\n"; #Returns the arg I passed > } > > In a running perl script on my apache the $r->args() doesn't return > anything. > > As I'm a newbie using mod_perl, a little help would be appreciated :) > What do you want to achieve?
In general I'd not recommend to change $r->args in a filter because a filter is run when input is consumed and that is somewhat besides the normal program flow. Normally apache consumes input only in the response phase. A handler like the default handler that has no use for input calls ap_discard_request_body() and thus reads the input calls all input filters and puts the result in the bin. A handler like mod_cgi processes the input but again, it consumes it only in the response phase. CGI environment variables are set earlier. So changing $r- >args in a filter cannot affect them. Instead use a PerlFixupHandler or so. PerlFixupHandler "sub {$_[0]->args(q{userId=10});0;}" Torsten