You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Scott Alexander <sc...@musiciansfriend.com> on 2000/06/29 22:01:52 UTC

getting data posted to site

I'm trying to get the data that is posted from the browser durring a 
request.

if ($r->method ne 'GET')
{
	$r->read($buffer,$r->header_in('Content-Length'));
	#proccess data...
}

The $r->read() hangs the request completely.  I ran an strace on 
httpd -X and posted the request section to 
http://mail.thefriend.com/httpd.strace.txt if that helps anyone.

Scott

Re: getting data posted to site

Posted by Roger Espel Llima <es...@iagora.net>.
Scott Alexander wrote:
> I'm trying to get the data that is posted from the browser durring a 
> request.
> 
> if ($r->method ne 'GET')
> {
> 	$r->read($buffer,$r->header_in('Content-Length'));
> 	#proccess data...
> }

There's a higher-level method for that, $r->content; I'd do something
like this:

if ($r->method eq 'POST' &&
    $r->header_in('Content-type') =~ m!^application/x-www-form-urlencoded!)
{
  my $data = $r->content;
  # process data ...
}

Although you should seriously consider using a higher-level interface,
such as Apache::Request (downloadable from mod_perl's ftp server under
the name "libapreq"), or CGI.pm.

-- 
Roger Espel Llima, espel@iagora.net
http://www.iagora.com/~espel/index.html

Re: getting data posted to site

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 29 Jun 2000, Scott Alexander wrote:

> I'm trying to get the data that is posted from the browser durring a 
> request.
> 
> if ($r->method ne 'GET')
> {
> 	$r->read($buffer,$r->header_in('Content-Length'));
> 	#proccess data...
> }
> 
> The $r->read() hangs the request completely.  I ran an strace on 

that normally happens because somebody already read the POST body.  are
you still having this problem?  the best way to figure out who is doing
this would be to use gdb:

% gdb httpd
(gdb) b ap_get_client_block
(gdb) source mod_perl-x.xx/.gdbinit
(gdb) run -X

now make a request:
(gdb) curinfo

should show the current Perl filename:linenumber

continue:
(gdb) c

and use curinfo the next time the breakpoint is hit.