Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Access to Apache 2 POST data?

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


jordan at viviotech

Dec 9, 2011, 11:45 AM

Post #1 of 4 (2697 views)
Permalink
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


pgollucci at gmail

Dec 9, 2011, 11:55 AM

Post #2 of 4 (2652 views)
Permalink
Re: Access to Apache 2 POST data? [In reply to]

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 [at] p6m7g8) 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.
Attachments: signature.asc (0.25 KB)


lloyd at protectchildren

Dec 9, 2011, 11:58 AM

Post #3 of 4 (2654 views)
Permalink
RE: Access to Apache 2 POST data? [In reply to]

while($r->read($buffer, 1024)) {}

Should do it.


-----Original Message-----
From: Jordan Michaels [mailto:jordan [at] viviotech]
Sent: December-09-11 1:46 PM
To: modperl [at] perl
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


jordan at viviotech

Dec 9, 2011, 2:38 PM

Post #4 of 4 (2660 views)
Permalink
Re: Access to Apache 2 POST data? [In reply to]

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 [at] viviotech]
> Sent: December-09-11 1:46 PM
> To: modperl [at] perl
> 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

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.