mp2 and post/get params

mp2 and post/get params

am 20.02.2008 18:54:22 von kirk

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

am 20.02.2008 19:00:08 von Colin Wetherbee

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

am 20.02.2008 20:41:45 von Perrin Harkins

On Feb 20, 2008 12:54 PM, 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

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