Modify POST request in mod_perl2
Asked Answered
D

2

6

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 ?

Deckle answered 21/6, 2010 at 9:16 Comment(0)
H
5

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.

Hygrophilous answered 21/6, 2010 at 10:4 Comment(0)
S
1

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.

Sunsunbaked answered 30/1, 2011 at 22:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.