Modify POST request in mod_perl2
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.
精彩评论