Apache2::Request

Apache2::Request

am 23.05.2008 10:49:55 von mome

Hi,

I am trying to use mod_perl2 with Apache2::Request. My intention is to get
parameter value of post method. As described in its document and previouse
threads said to cache the data with post method...
"....Use Apache2::Request in the auth handler, and apreq
will do the SOMETHING you need automatically."

My existing code i.e. handler begins with
sub my_handler {
my $self = shift;
my $r = shift;
.....
....
I guess that $r refers to Apache2::RequestRec object because the lines
that follows use methods of this object.

With the little knowledge, I don't know why calling $r = shift returns
Apache2::RequestRec.
How can I make use Apache2::Request in my handler so I can preseve the
parameter via post method?

I tried the following line without success

sub my_handler {
my $self = shift;
my $r = shift;
my $req = Apache2::Request->new($r, POST_MAX => "1M");
....
....
}
Please advice.

PA










--
View this message in context: http://www.nabble.com/Apache2%3A%3ARequest-tp17420698p174206 98.html
Sent from the mod_perl - General mailing list archive at Nabble.com.

Re: Apache2::Request

am 23.05.2008 13:59:52 von xyon

Shouldn't it be:

sub my_handler {
my $r = shift;
my $req = Apache2::Request->new($r, POST_MAX => "1M");
....


On Friday 23 May 2008 04:49:55 mome wrote:
> Hi,
>
> I am trying to use mod_perl2 with Apache2::Request. My intention is to get
> parameter value of post method. As described in its document and previouse
> threads said to cache the data with post method...
> "....Use Apache2::Request in the auth handler, and apreq
> will do the SOMETHING you need automatically."
>
> My existing code i.e. handler begins with
> sub my_handler {
> my $self = shift;
> my $r = shift;
> ....
> ...
> I guess that $r refers to Apache2::RequestRec object because the lines
> that follows use methods of this object.
>
> With the little knowledge, I don't know why calling $r = shift returns
> Apache2::RequestRec.
> How can I make use Apache2::Request in my handler so I can preseve the
> parameter via post method?
>
> I tried the following line without success
>
> sub my_handler {
> my $self = shift;
> my $r = shift;
> my $req = Apache2::Request->new($r, POST_MAX => "1M");
> ...
> ...
> }
> Please advice.
>
> PA



--

xyon

Re: Apache2::Request

am 23.05.2008 16:29:21 von Adam Prime

Quoting xyon :

> Shouldn't it be:
>
> sub my_handler {
> my $r = shift;
> my $req = Apache2::Request->new($r, POST_MAX => "1M");
> ...
>

Provided that you've actually installed libapreq
(http://httpd.apache.org/apreq/), that should work.

Re: Apache2::Request

am 23.05.2008 19:01:34 von Perrin Harkins

On Fri, May 23, 2008 at 4:49 AM, mome wrote:
> I tried the following line without success
>
> sub my_handler {
> my $self = shift;
> my $r = shift;
> my $req = Apache2::Request->new($r, POST_MAX => "1M");

You only want that additional shift at the beginning if you are
calling your handler as a method. You probably aren't, since you
don't have a "method" sub attribute here. That means that the request
object ($r) will be the first thing passed, not the second. There is
no $self when calling handlers as subs.

- Perrin

Re: Apache2::Request

am 23.05.2008 19:30:53 von John Drago

--- adam.prime@utoronto.ca wrote:

> Quoting xyon :
>
> > Shouldn't it be:
> >
> > sub my_handler {
> > my $r = shift;
> > my $req = Apache2::Request->new($r, POST_MAX =>
> "1M");
> > ...
> >
>
> Provided that you've actually installed libapreq
> (http://httpd.apache.org/apreq/), that should work.
>
>


Your mod_perl handler is passed either 1 or 2
parameters, depending on how you declare your method.

Example:

sub handler {
my ($r) = @_;
}


sub handler : method {
my ($class, $r) = @_;
}

In either case, $r is an Apache2::RequestRec. The
difference is the ": method" attribute that tells
mod_perl to pass your "handler" sub 2 parameters
instead of just 1.

- John Drago
http://www.devstack.com
http://search.cpan.org/dist/Apache2-ASP