[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    RE: problem with content()
From:       Jie Gao <J.Gao () isu ! usyd ! edu ! au>
Date:       1999-02-28 4:00:19
[Download RAW message or body]

On Sat, 27 Feb 1999, Eric Cholet wrote:

> On Saturday, February 27, 1999 4:25 AM, Jie Gao 
> [SMTP:J.Gao@isu.usyd.edu.au] wrote:
> > On Tue, 23 Feb 1999, Doug MacEachern wrote:
> >
> > > At 06:54 PM 2/21/99 +1100, Jie Gao wrote:
> > > >Hi everybody,
> > > >
> > > >I am seeking advice about a problem I'm having with Apache Request's
> > > >content().
> > > >
> > > >I am trying to get my PerlAuthenHandler work to authenticate on some 
> of
> > > >the name=value pairs passed to a program on the server. As the
> > > ><Location xxxx> does not cover the query string ("?a=b"), I managed to
> > > >handle it within the handler using r->uri without much problem.
> > > >
> > > >However, it turned out the program (a commercial product, the 
> internals
> > > >of which is not accessible), also passes the indentifying parameter
> > > >pairs from forms using "application/x-www-form-urlencoded". This 
> causes
> > > >additional problem, for I would need to parse the form input to find
> > > >those pairs.
> > > >
> > > >The only mothod of doing this, as far as I can find, is to use the
> > > >"$r->content" way. But, all of you must have already known it, the
> > > >method can only be called once. It worked OK for authentication, but
> > > >after that, the program seemed unable to find those parameters any
> > > >more.
> > > >
> > > >Is there any way out of this?
> > >
> > > The only way out in this case, is to have an early handler, e.g.
> > > PerlPostReadRequestHandler, read in $r->content as a raw string, set
> > > $r->args to that string, and switch the $r->method to "GET" and
> > > $r->method_number to M_GET.  Provided your commercial product can 
> handle a
> > > GET request, of course.
> >
> > Thanks, Doug. I wrote a handler according to the above, but I don't
> > seem to be able to put it in <Location>, <Directory> or <Files>
> > directive sections:
> >
> > <Location "/cgi-bin/test.pl">
> > PerlPostReadRequestHandler My::MyTransPostToGet
> > PerlAuthenHandler My::AuthCookieHandler->authen
> > PerlAuthzHandler My::AuthCookieHandler->authz
> > AuthName Authen
> > PerlSetVar AuthenQueryValue site=testsite:enter=testing:join=testing
> > ...
> > </Location>
> >
> > root@banquo/<2>apache/conf:28> ../bin/apachectl configtest
> > Syntax error on line 209 of 
> /usr/local/apache_1.3.4_mod_ssl/conf/access.conf:
> > PerlPostReadRequestHandler not allowed here
> >
> > My mod_perl was compiled with EVERYTHING=1.
> >
> >
> Jie,
> 
> You can't put a PostReadRequestHandler in a <Location> or <Directory> 
> section, because PostReadRequest occurs before the Translation phase, 
> therefore the <Location> isn't known at that time.
> 
> Either place your PostReadRequestHandler outside any sections, and test 
> $r->uri in the code, or you can maybe do your thing in a later phase, 
> PerlHeaderParserHandler is the first one that can be put inside a 
> <Location>, <Directory> or htaccess.
> 
> I've done something similar in a AccessHandler.

Thanks a lot for the tip. I've got it work now. :) I used the 
PostReadRequestHandler/$r->uri testing method.

mod_perl is great!


Jie

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic