You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Kirk <ki...@icapsolutions.com> on 2008/02/20 18:54:22 UTC

mp2 and post/get params

I'm new to mp2 and have a relatively old application that used the mp1
implementation of grabbing get/post params from incoming requests:


$r = shift;

# grab incoming value 
my $value = $r->param('name');
...
...
# assign some value
$r->param('key' => 'val');

And of course, I need to consolidate both request type into one hash or
string so I can access either, or both, on demand.

What is the equivalent in mp2?  I can't seem to find a general answer in the
docs and it's a bit confusing where this functionality disappeared to.

Thx,
Kirk




Re: mp2 and post/get params

Posted by Colin Wetherbee <cw...@denterprises.org>.
Kirk wrote:
> I'm new to mp2 and have a relatively old application that used the mp1
> implementation of grabbing get/post params from incoming requests:
> 
> 
> $r = shift;
> 
> # grab incoming value 
> my $value = $r->param('name');
> ...
> ...
> # assign some value
> $r->param('key' => 'val');
> 
> And of course, I need to consolidate both request type into one hash or
> string so I can access either, or both, on demand.
> 
> What is the equivalent in mp2?  I can't seem to find a general answer in the
> docs and it's a bit confusing where this functionality disappeared to.

I use the following in mod_perl 2.

my $r = Apache2::RequestUtil->request;
my $req = Apache2::Request->new($r);

my $foo = $req->param('foo');

Colin


Re: mp2 and post/get params

Posted by Perrin Harkins <pe...@elem.com>.
On Feb 20, 2008 12:54 PM, Kirk <ki...@icapsolutions.com> wrote:
> I'm new to mp2 and have a relatively old application that used the mp1
> implementation of grabbing get/post params from incoming requests

Use Apache2::Request (in the libapreq2 distribution on CPAN) or CGI.pm.

> # assign some value
> $r->param('key' => 'val');

You can't do that anymore.  You should never have been able to.  The
request params show you what the client sent in.  You can't change the
past.

If you need to keep track of internal filtering and changes to params,
just make your own data structure for them and copy in what you want
from the original params.

> And of course, I need to consolidate both request type into one hash or
> string so I can access either, or both, on demand.

Both Apache2::Request and CGI handle this.

- Perrin