You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by "Baillargeon, Sonny" <So...@bmonb.com> on 2004/01/09 16:33:01 UTC

FW: Help with Apache::Request module

> I have been trying to get mason to work with mod_perl and I am getting
> the following error:
> 
> [Fri Jan 09 09:30:59 2004] [error] [client 10.111.41.38] Can't locate
> auto/Apache/Request/instance.al in @INC (@INC contains:
> /home/sbaillar/perllib/Apache2
> /opt/ActivePerl-5.8/lib/site_perl/5.8.0/sun4-solaris-thread-multi/Apac
> he2 /home/sbaillar/perllib
> /opt/ActivePerl-5.8/lib/5.8.0/sun4-solaris-thread-multi
> /opt/ActivePerl-5.8/lib/5.8.0
> /opt/ActivePerl-5.8/lib/site_perl/5.8.0/sun4-solaris-thread-multi
> /opt/ActivePerl-5.8/lib/site_perl/5.8.0
> /opt/ActivePerl-5.8/lib/site_perl . /apps/apache-2.0.47/
> /apps/apache-2.0.47/lib/perl) at
> /home/sbaillar/perllib/HTML/Mason/ApacheHandler.pm line 808
> 
> instance.al doesn't exist nor can I find it in any google searches.  I
> have recompiled both libareq2.02-dev and Mason but to no avail.  What
> else can this be?
> 
> My http.conf, perl.conf, and startup.pl is attached.
> 
> Thanks for your help.
> 
> -sonny <<startup.pl>>  <<perl.conf>>  <<httpd.conf>> 


<FONT SIZE = 1>****************************************************************************
This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this e-mail and destroy any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. Unless otherwise stated, opinions expressed in this e-mail are those of the author and are not endorsed by the author's employer.</FONT>


Re: FW: Help with Apache::Request module

Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
> Stas Bekman <st...@stason.org> writes:
> 
> 
>>Joe Schaefer wrote:
> 
> 
> [...]
> 
> 
>>I forgot the CGI spec on this issue.
> 
> 
> The "CGI spec" has nothing to say about this...

OK, so CGI.pm is the spec.

>>But what happens if you ask for a single value, and there is more than
>>one. Should it return the first one it has encountered? What happens
>>if there is a second one?
> 
>  
> Well, we try to emulate CGI::param, so Apache::Request::param should
> have the same (context-sensitive) behavior that CGI::param does.  I
> don't know what else there is to say here.

Sounds good to me :)


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: FW: Help with Apache::Request module

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:

> Joe Schaefer wrote:

[...]

> I forgot the CGI spec on this issue.

The "CGI spec" has nothing to say about this...

> But what happens if you ask for a single value, and there is more than
> one. Should it return the first one it has encountered? What happens
> if there is a second one?
 
Well, we try to emulate CGI::param, so Apache::Request::param should
have the same (context-sensitive) behavior that CGI::param does.  I
don't know what else there is to say here.

-- 
Joe Schaefer


Re: FW: Help with Apache::Request module

Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
> Stas Bekman <st...@stason.org> writes:
> 
> 
>>Joe Schaefer wrote:
> 
> 
> [...]
> 
> 
>>>  sub auth_handler {
>>>        my $req = Apache::Request->new(shift);
>>>        if ($req->param("password") eq "foo") {
>>>            return OK;
>>>        }                else {
>>>            return AUTH_ERROR;
>>>        }
>>>  }
>>>The scalar $req->param call will cause libapreq2 to keep fetching POST
>>>data until it's found the "password" param.  If that param is near
>>>the front of the POST body, then libapreq2 will have only fetched
>>>about 64KB before returning from the param() call.
>>
>>What happens if there are two 'password' key/val pairs in the input?
>>Does it know from the context whether one is enough? .e.g will:
>>
>>   @passwords = $req->param("password");
>>
>>deterministically consume all the input?
> 
> 
> I'm not sure what the current code actually does (there's this strange
> prefetch apreq_cfg_t attribute I've been meaning to remove), but IMO 
> what it should do here is parse the entire POST.  So yes, the behavior 
> would be context-sensitive.

Good. Thanks Joe.

I forgot the CGI spec on this issue. But what happens if you ask for a single 
value, and there is more than one. Should it return the first one it has 
encountered? What happens if there is a second one?


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: FW: Help with Apache::Request module

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:

> Joe Schaefer wrote:

[...]

> >   sub auth_handler {
> >         my $req = Apache::Request->new(shift);
> >         if ($req->param("password") eq "foo") {
> >             return OK;
> >         }                else {
> >             return AUTH_ERROR;
> >         }
> >   }
> > The scalar $req->param call will cause libapreq2 to keep fetching POST
> > data until it's found the "password" param.  If that param is near
> > the front of the POST body, then libapreq2 will have only fetched
> > about 64KB before returning from the param() call.
> 
> What happens if there are two 'password' key/val pairs in the input?
> Does it know from the context whether one is enough? .e.g will:
> 
>    @passwords = $req->param("password");
> 
> deterministically consume all the input?

I'm not sure what the current code actually does (there's this strange
prefetch apreq_cfg_t attribute I've been meaning to remove), but IMO 
what it should do here is parse the entire POST.  So yes, the behavior 
would be context-sensitive.

-- 
Joe Schaefer


Re: FW: Help with Apache::Request module

Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
> Geoffrey Young <ge...@modperlcookbook.org> writes:
> 
> [...]
> 
> 
>>just one thing of interest.  if the client posts 10MB (assuming it passes
>>the configured POST limit) then all 10MB are always cached? 
> 
> 
> It actually depends on what's going on with the handlers themselves.
> If the first handler is an auth handler which uses libapreq2, then
> the unless the handler NEEDS all 10MB, libapreq2 will just fetch
> enough data for the handler to make its decision.  For instance, if
> it needs to check whether a POST parameter named "password" was set to 
> "foo":
> 
>   sub auth_handler {
>         my $req = Apache::Request->new(shift);
> 
>         if ($req->param("password") eq "foo") {
>             return OK;
>         }        
>         else {
>             return AUTH_ERROR;
>         }
>   }
> 
> The scalar $req->param call will cause libapreq2 to keep fetching POST
> data until it's found the "password" param.  If that param is near
> the front of the POST body, then libapreq2 will have only fetched 
> about 64KB before returning from the param() call.  

What happens if there are two 'password' key/val pairs in the input? Does it 
know from the context whether one is enough? .e.g will:

   @passwords = $req->param("password");

deterministically consume all the input?




__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: FW: Help with Apache::Request module

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>>I can patch Request_pod to that effect if I have my info correct.
> 
> 
> Cool!

attached.

I put the docs under the instance() method.  my thought was that after a
release or two it could go further down in a porting section or something,
but that placing it earlier would make it more apparent for new users.

feel free to tweak, rearrange, or otherwise alter it :)

--Geoff

Re: FW: Help with Apache::Request module

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> If the "password" param never appears, then libapreq2 will gobble up the 
> entire POST data before giving up, with param() returning undef.  At
> this point the POST is data is both parsed (into $req->body) and spooled
> (to disk if the POST is larger than 256KB) by the mod_apreq filter.

wow.  that's some cool stuff you guys have done.  kudos.  sorry I wasn't
around to help.  I tried tracing some of the calls around but quickly got
lost in a jumble of defines - getting in at the start would have helped :)

> I wasn't aware of a significant difference in memory footprint between
> instance() and new() in mp1 (the reason being that the underlying C 
> strings representing libapreq's parser output are always allocated from
> the request pool, so they're not cleaned up until the request pool 
> is destroyed).

doh, my bad.  it's the object that's passed around, not the data.  duh.

>>I can patch Request_pod to that effect if I have my info correct.
> 
> 
> Cool!

forthcoming soonish.

--Geoff


Re: FW: Help with Apache::Request module

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Geoffrey Young <ge...@modperlcookbook.org> writes:

[...]

> just one thing of interest.  if the client posts 10MB (assuming it passes
> the configured POST limit) then all 10MB are always cached? 

It actually depends on what's going on with the handlers themselves.
If the first handler is an auth handler which uses libapreq2, then
the unless the handler NEEDS all 10MB, libapreq2 will just fetch
enough data for the handler to make its decision.  For instance, if
it needs to check whether a POST parameter named "password" was set to 
"foo":

  sub auth_handler {
        my $req = Apache::Request->new(shift);

        if ($req->param("password") eq "foo") {
            return OK;
        }        
        else {
            return AUTH_ERROR;
        }
  }

The scalar $req->param call will cause libapreq2 to keep fetching POST
data until it's found the "password" param.  If that param is near
the front of the POST body, then libapreq2 will have only fetched 
about 64KB before returning from the param() call.  

If the "password" param never appears, then libapreq2 will gobble up the 
entire POST data before giving up, with param() returning undef.  At
this point the POST is data is both parsed (into $req->body) and spooled
(to disk if the POST is larger than 256KB) by the mod_apreq filter.

> is this configurable, so that end-users can specify whether this is
> desirable for their application?  part of the reason we introduced
> instance() (over overriding new() ) was to let users have a choice in
> the matter.

I wasn't aware of a significant difference in memory footprint between
instance() and new() in mp1 (the reason being that the underlying C 
strings representing libapreq's parser output are always allocated from
the request pool, so they're not cleaned up until the request pool 
is destroyed).

> anyway, I guess the answer to future questions about instance() is
> that the functionality has been integrated into new(), making
> instance() unnecessary in libapreq2.  not merely that instance()
> hasn't been ported or isn't around anymore.

+1.

> I can patch Request_pod to that effect if I have my info correct.

Cool!
-- 
Joe Schaefer


Re: FW: Help with Apache::Request module

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> 
>>but in any case that's not exactly the same thing.  
> 
> 
> Can you explain what the difference _should_ be?

oh, sorry.  what I meant was that new() doesn't behave the same as
instance().  the code you had in mind just makes them aliases.  but that may
be sufficient if the below is true.

>>is there a technical reason why instance() is gone from libapreq2?
> 
> 
> Not at all-  I'm +1 for supporting it, somehow.  It's just that
> since Apache::Request::new() always fetches the cached data now, 
> I'm not sure what role Apache::Request::instance() would play.

ah!  I hadn't realized that the data is always cached.  if that's true, then
I don't see a reason to support instance() specifically - the port to
libapreq2 is fairly straightforward.

just one thing of interest.  if the client posts 10MB (assuming it passes
the configured POST limit) then all 10MB are always cached?  is this
configurable, so that end-users can specify whether this is desirable for
their application?  part of the reason we introduced instance() (over
overriding new() ) was to let users have a choice in the matter.

anyway, I guess the answer to future questions about instance() is that the
functionality has been integrated into new(), making instance() unnecessary
in libapreq2.  not merely that instance() hasn't been ported or isn't around
anymore.

I can patch Request_pod to that effect if I have my info correct.

--Geoff



Re: FW: Help with Apache::Request module

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> With libapreq2, there's no Apache::Request::instance() method.  You can
> try supplying one by just binding to new() during your startup.pl:
> 
>   *Apache::Request::instance = *Apache::Request::new; # or somesuch *-thingy

*Apache::Request::instance = \&Apache::Request::new;

:)

but in any case that's not exactly the same thing.  is there a technical
reason why instance() is gone from libapreq2?  I volunteer to do the c/xs
wrapper if it's only because the perl wrapper didn't fit easily into the
framework.

--Geoff


Re: FW: Help with Apache::Request module

Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Baillargeon, Sonny" <So...@bmonb.com> writes:

[...]

> > instance.al doesn't exist nor can I find it in any google searches.  I
> > have recompiled both libareq2.02-dev and Mason but to no avail.  What
> > else can this be?

With libapreq2, there's no Apache::Request::instance() method.  You can
try supplying one by just binding to new() during your startup.pl:

  *Apache::Request::instance = *Apache::Request::new; # or somesuch *-thingy

Let me know if this helps or not.

-- 
Joe Schaefer