Thanks for your explanation concerning the request processing (I think it
corresponds to the drawing I've seen 
http://perl.apache.org/docs/2.0/user/handlers/http_cycle.gif here ) I
understand it much better now :)

The fact is that in order to add this arg to the request I need to call
several Web services, crypt and decrypt datas and access the cookies I've
previously stored in the clients navigator.

Is it also possible in this type of handler? (I've already tested all these
actions in an InputFilter and it works fine).

Thanks again.

Ivory

Torsten Foertsch wrote:
> 
> 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
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Adding-args-to-a-Request-through-InputFilter-tp27228223p27239686.html
Sent from the mod_perl - General mailing list archive at Nabble.com.

Reply via email to