Re: APR::Request::Apache2 param() method

Dave Viner <[email protected]>
Newsgroups gmane.comp.apache.apreq
Message-ID <[email protected]>
removing the enctype makes no difference.  still encounter the same  
error.

i also added discard_request_body...  the code now reads:

     my $req = APR::Request::Apache2->handle($r);
     $r->discard_request_body;
     my($arg_status,$body_status) = $req->param_status();
     $r->log->debug("Parsing returned $arg_status, $body_status");  
#this is line 43

     if($r->method_number() == Apache2::Const::M_POST)
     {
         my $ps = $req->param();
         foreach my $k (keys(%$ps))
         {
             $r->log->warn("Got $k => " . $ps->{$k});
         }
         ## verify that we got an  alert id
         my $alert_id = $req->param('alerts_id');
         my $alert_email = $req->param('alerts_email');
         $r->log->debug("!!!!!!!!!!!! Checking params");
         if(!$alert_id)
         {
             $r->log->warn("no alert id given");



here's the output in the error log:

[Wed Jan 31 13:17:32 2007] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/MailingList/Remove.pm(17): [client  
127.0.0.1] using mod_perl handler for removing mailing list, referer:  
http://lalala.aboutmybaby.localhost/mailing_list/remove? 
[email protected]
Use of uninitialized value in concatenation (.) or string at /Users/ 
dviner/Documents/amb/dev/aboutmybaby/AMB/Handlers/MailingList/ 
Remove.pm line 43.
[Wed Jan 31 13:17:32 2007] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/MailingList/Remove.pm(43): [client  
127.0.0.1] Parsing returned Missing input data, , referer: http:// 
lalala.aboutmybaby.localhost/mailing_list/remove? 
[email protected]
[Wed Jan 31 13:17:32 2007] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/MailingList/Remove.pm(55): [client  
127.0.0.1] !!!!!!!!!!!! Checking params, referer: http:// 
lalala.aboutmybaby.localhost/mailing_list/remove? 
[email protected]
[Wed Jan 31 13:17:32 2007] [warn] [client 127.0.0.1] no alert id  
given, referer: http://lalala.aboutmybaby.localhost/mailing_list/ 
[email protected]


I also tried to verify my sanity by using CGI.pm to print out what  
the parameters are that are received...
here's that output and code:

[Wed Jan 31 13:23:30 2007] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/MailingList/Remove.pm(18): [client  
127.0.0.1] using mod_perl handler for removing mailing list, referer:  
http://lalala.aboutmybaby.localhost/mailing_list/remove? 
[email protected]
Use of uninitialized value in concatenation (.) or string at /Users/ 
dviner/Documents/amb/dev/aboutmybaby/AMB/Handlers/MailingList/ 
Remove.pm line 44.
[Wed Jan 31 13:23:30 2007] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/MailingList/Remove.pm(44): [client  
127.0.0.1] Parsing returned Missing input data, , referer: http:// 
lalala.aboutmybaby.localhost/mailing_list/remove? 
[email protected]
[Wed Jan 31 13:23:30 2007] [warn] [client 127.0.0.1] Got [CGI]  
alerts_id => 44524, referer: http://lalala.aboutmybaby.localhost/ 
mailing_list/[email protected]
[Wed Jan 31 13:23:30 2007] [warn] [client 127.0.0.1] Got [CGI]  
alerts_email => [email protected], referer: http:// 
lalala.aboutmybaby.localhost/mailing_list/remove? 
[email protected]
[Wed Jan 31 13:23:30 2007] [warn] [client 127.0.0.1] Got [CGI] submit  
=> Remove, referer: http://lalala.aboutmybaby.localhost/mailing_list/ 
[email protected]
[Wed Jan 31 13:23:30 2007] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/MailingList/Remove.pm(62): [client  
127.0.0.1] !!!!!!!!!!!! Checking params, referer: http:// 
lalala.aboutmybaby.localhost/mailing_list/remove? 
[email protected]
[Wed Jan 31 13:23:30 2007] [warn] [client 127.0.0.1] no alert id  
given, referer: http://lalala.aboutmybaby.localhost/mailing_list/ 
[email protected]

CODE:

     my $req = APR::Request::Apache2->handle($r);
     $r->discard_request_body;
     my($arg_status,$body_status) = $req->param_status();
     $r->log->debug("Parsing returned $arg_status, $body_status");

     if($r->method_number() == Apache2::Const::M_POST)
     {
         my $ps = $req->param();
         foreach my $k (keys(%$ps))
         {
             $r->log->warn("Got [APR::Request::Apache2] $k => " . $ps- 
 >{$k});
         }
         my $cgi = CGI->new($r);
         my $pscgi = $cgi->Vars();
         foreach my $k (keys(%$pscgi))
         {
             $r->log->warn("Got [CGI] $k => " . $pscgi->{$k});
         }
         ## verify that we got an  alert id
         my $alert_id = $req->param('alerts_id');
         my $alert_email = $req->param('alerts_email');
         $r->log->debug("!!!!!!!!!!!! Checking params");
         if(!$alert_id)
         {
             $r->log->warn("no alert id given");


How is it that CGI.pm finds the parameter and APR::Request::Apache2  
does not??

thanks
dave




On Jan 30, 2007, at 12:49 PM, Joe Schaefer wrote:

> Dave Viner <[email protected]> writes:
>
>> Hi,
>>
>> I am having a strange problem with APR::Request::Apache2 and the  
>> param
>> () method.  When I send a POST from Firefox, my code works  
>> perfectly.  When I
>> send a POST from Safari or Windows/IE, my code fails.
>>
>> Here is the HTML which displays the form to send:
>>         <form name="delete_alert" action="/mailing_list/remove"  
>> method="post"
>> enctype="multipart/form-data">
>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Have you tried it with the default enctype?
>
>>         <input type="hidden" name="alerts_id" value="1234" />
>>         <input type="hidden" name="alerts_email"  
>> value="[email protected]">
>>         <input type="submit" name="submit" value="Remove">
>>         <input type="button" name="cancel" value="Cancel"
>> onclick="document.location='/'; return false;">
>>         <br class="clearing">
>>         </form>
>>
>> Here is the Perl code which handles this request:
>>
>>     my $req = APR::Request::Apache2->handle($r);
>
> Try adding
>
>       $r->discard_request_body;
>
> here, and then see what the body_status is.
> (The code didn't croak, so I don't think you're getting
> an error, but let's see anyhow).
>
> -- 
> Joe Schaefer
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.