Does anyone know how to access/modify the POST request data using mod_perl2. IN GET method one can get/set the request QUERY string:
$args = $r->args();
$prev_args = $r->args($new_args);
How to get/set the request QUERY string in POST method ?
Get POST parameters with Apache2::Request::param
.
To set, first get an APR::Request::Param::Table
object from the body
method. Rebless
it into an APR::Table
object, then use its methods to manipulate the data.
I use this mod_perl2 code snippet to successfully parse out a form's field value submitted via POST method:
use CGI;
my $req = CGI->new($r);
my $field_value = $req->param('form_field');
If you don't use CGI;
as illustrated above, and instead, use the following code:
my $req = Apache2::Request->new($r);
my $field_value = $req->param('form_field');
You'll probably succeed in GET method. However, while getting request via POST method, in my case, I got into infinite loop of some king of 'prefetching filter.c(270) error' and the request will never return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With