Re: Access to Apache 2 POST data?

Jordan Michaels <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
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:[email protected]]
> Sent: December-09-11 1:46 PM
> To: [email protected]
> 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
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.