You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Dave Viner <da...@pobox.com> on 2006/09/22 20:03:40 UTC

use libapreq2 to read POST params

Hi,
I'm trying to use libapreq2 to read some parameters submitted via  
POST, but I'm having trouble.  Should I use $req->body($myparam) ? or  
$req->param($myparam)?


My code looks like this:

         $r->log->debug("Testing param");
         my ($md5, $entered);
         eval { $md5 = $req->param('cv'); } ;
         if($@)
         {
             use Data::Dumper;
             $r->log->error("ACK: no cv param: " . $@->strerror() . "  
-- " . Dumper($@));
             return $class->handle_get($r, $Site, $req,
                                     'The code entered was not  
valid.<br>Please try again.');
         }
         $r->log->debug("For cv got... $md5");


The error log shows the following:

[Fri Sep 22 10:59:56 2006] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/GuestbookSign.pm(57): [client 127.0.0.1]  
Testing param
[Fri Sep 22 10:59:56 2006] [debug] filter.c(269): [client 127.0.0.1]  
prefetching 65536 bytes
Use of uninitialized value in concatenation (.) or string at /Users/ 
dviner/Documents/amb/dev/aboutmybaby/AMB/Handlers/GuestbookSign.pm  
line 67.
[Fri Sep 22 10:59:56 2006] [debug] /Users/dviner/Documents/amb/dev/ 
aboutmybaby/AMB/Handlers/GuestbookSign.pm(67): [client 127.0.0.1] For  
cv got...


The request I sent is as follows:

$ cat sign.params | lwp-request -m POST -SUsue "http:// 
lalala.aboutmybaby.localhost/guestbook/sign"
$ cat sign.params
gbentry_from=hithere&gbentry_body=foobar&cv=1111111&cg=abcdef

$

Here are the details of my installation:

[Fri Sep 22 10:59:55 2006] [notice] Apache/2.0.58 (Unix) PHP/5.1.4  
DAV/2 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 configured  
-- resuming normal operations


Thanks for your help.
Dave Viner




Re: use libapreq2 to read POST params

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Dave Viner wrote:
> Hi,
> I'm trying to use libapreq2 to read some parameters submitted via POST, 
> but I'm having trouble.  Should I use $req->body($myparam) ? or 
> $req->param($myparam)?
...[snip]....
cv=1234


pgollucci@pgollucci.office.tmcs /home/pgollucci/dev/build 466 0>cat params | lwp-request -m POST -SUsue 
http://test.p6m7g8.net/post
POST http://test.p6m7g8.net/post
User-Agent: lwp-request/2.07
Content-Length: 10
Content-Type: application/x-www-form-urlencoded

POST http://test.p6m7g8.net/post --> 200 OK
Connection: close
Date: Fri, 22 Sep 2006 19:17:13 GMT
Server: Apache/2.2.0 (FreeBSD) mod_ruby/1.2.5 Ruby/1.8.4(2005-12-24) PHP/4.4.2 mod_apreq2-20051231/2.5.7 mod_perl/2.0.2 
Perl/v5.8.8
Content-Type: text/plain
Client-Date: Fri, 22 Sep 2006 19:17:09 GMT
Client-Peer: 66.236.219.72:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked

cv => 1234

Code and config available:
http://test.p6m7g8.net/TEST

See also:
http://httpd.apache.org/apreq/docs/libapreq2/group__apreq__xs__apr__request.html#param

HTH



-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."
    __  ___     ___ ____  __
   /  |/  /_ __/ __/ __ \/ /
  / /|_/ / // /\ \/ /_/ / /__
/_/  /_/\_, /___/\___\_\___/
        <___/