You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jordan Michaels <jo...@viviotech.net> on 2011/12/09 20:45:40 UTC

Access to Apache 2 POST data?

I'm looking for a way to pass HTTP POST data from a POST request to a 
subrequest, however, I can't find any methods in the mod_perl API that 
deal with a HTTP POST request body.

Apche 1 mod_perl had $r->content, but that doesn't appear to be present 
in Apache 2 mod_perl. Can anyone point me to the replacement? I'm sure 
I'm just missing it.

If there's not a $r->content equivalent, maybe there's a bucket brigade 
workaround or something along those lines? I just need to be pointed in 
the right direction.

Thank you in advance for your help!

-- 
Warm Regards,
Jordan Michaels

Re: Access to Apache 2 POST data?

Posted by "Philip M. Gollucci" <pg...@gmail.com>.
On 12/09/11 19:45, Jordan Michaels wrote:
> I'm looking for a way to pass HTTP POST data from a POST request to a
> subrequest, however, I can't find any methods in the mod_perl API that
> deal with a HTTP POST request body.
> 
> Apche 1 mod_perl had $r->content, but that doesn't appear to be present
> in Apache 2 mod_perl. Can anyone point me to the replacement? I'm sure
> I'm just missing it.
> 
> If there's not a $r->content equivalent, maybe there's a bucket brigade
> workaround or something along those lines? I just need to be pointed in
> the right direction.
> 
> Thank you in advance for your help!
> 
Look at apreq.


-- 
------------------------------------------------------------------------
1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70  3F8C 75B8 8FFB DB9B 8C1C
Philip M. Gollucci (pgollucci@p6m7g8.com) c: 703.336.9354
Member,                           Apache Software Foundation
Committer,                        FreeBSD Foundation
Consultant,                       P6M7G8 Inc.
Director Operations,              Ridecharge Inc.

Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.


Re: Access to Apache 2 POST data?

Posted by Jordan Michaels <jo...@viviotech.net>.
This looks like it will work nicely. For historical / search engine 
purposes, the read() function is part of the Apache2::RequestIO package. 
Here's an example implementation:

----------------------------
use Apache2::RequestIO   ();
use Apache2::RequestUtil ();
use Apache2::RequestRec  ();
use Apache2::Log         ();

use Apache2::Const -compile => qw(OK DECLINED :log);

sub handler {
	my $r = shift;

	# handle POST requests
	if ( $r->method() eq "POST" ) {
		
		# create a post data buffer
		my $PostBuffer = '';
		
		# loop over each line of data
		while($r->read($PostBuffer, 1024)) {
			$r->log->notice("[mod_cfml] Post Data '$PostBuffer' ");
		}
	}
}
----------------------------

With this, I got the following in my Apache error_log:

[Fri Dec 09 14:25:54 2011] [notice] [client 127.0.0.1] [mod_cfml] Post 
Data 'stuff='

Which is exactly what I wanted, as I was submitting a blank form field 
called "stuff" as a test.

Thanks Lloyd! =)

Warm Regards,
Jordan Michaels

On 12/09/2011 11:58 AM, Lloyd Richardson wrote:
> while($r->read($buffer, 1024)) {}
>
> Should do it.
>
>
> -----Original Message-----
> From: Jordan Michaels [mailto:jordan@viviotech.net]
> Sent: December-09-11 1:46 PM
> To: modperl@perl.apache.org
> Subject: Access to Apache 2 POST data?
>
> I'm looking for a way to pass HTTP POST data from a POST request to a subrequest, however, I can't find any methods in the mod_perl API that deal with a HTTP POST request body.
>
> Apche 1 mod_perl had $r->content, but that doesn't appear to be present in Apache 2 mod_perl. Can anyone point me to the replacement? I'm sure I'm just missing it.
>
> If there's not a $r->content equivalent, maybe there's a bucket brigade workaround or something along those lines? I just need to be pointed in the right direction.
>
> Thank you in advance for your help!
>
> --
> Warm Regards,
> Jordan Michaels

RE: Access to Apache 2 POST data?

Posted by Lloyd Richardson <ll...@protectchildren.ca>.
while($r->read($buffer, 1024)) {}

Should do it.


-----Original Message-----
From: Jordan Michaels [mailto:jordan@viviotech.net] 
Sent: December-09-11 1:46 PM
To: modperl@perl.apache.org
Subject: Access to Apache 2 POST data?

I'm looking for a way to pass HTTP POST data from a POST request to a subrequest, however, I can't find any methods in the mod_perl API that deal with a HTTP POST request body.

Apche 1 mod_perl had $r->content, but that doesn't appear to be present in Apache 2 mod_perl. Can anyone point me to the replacement? I'm sure I'm just missing it.

If there's not a $r->content equivalent, maybe there's a bucket brigade workaround or something along those lines? I just need to be pointed in the right direction.

Thank you in advance for your help!

--
Warm Regards,
Jordan Michaels