You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Geoffrey Young <ge...@modperlcookbook.org> on 2004/11/29 15:21:26 UTC

Re: [mp1] multiple handlers?


Tony Clayton wrote:
> Hi,
> 
> I am using a 3rd party compiled apache module that implements a
> response handler, but DECLINES all the other handlers with no
> processing.
> 
> I want to do authentication in mod_perl before calling the handler,
> based on some custom HTTP headers sent by the client.  I understand
> that mod_perl lets you chain handlers, but that this is not a regular
> apache feature.

the chaining mod_perl allows and the "chaining" you are asking for are
different things - see below.

> 
> Is there a way to use a PerlAuthenHandler and a non-perl response
> handler in the same Location directive, or am I going to be stuck
> writing a PerlHandler to handle the request, and spawn an apache
> subrequest from that to run the other handler?

using a PerlAuthenHandler in no way affects who can run in any other apache
phase, such as fixups or (in your case) content generation.  well, outside
of the normal duties of an authen handler, anyway :)

I would suggest that you take a moment to read up on the apache lifecycle if
you want to understand things a bit more clearly.  this is as good a place
as any:

  http://www.modperlcookbook.org/chapters/part3.pdf

take a look at the diagram, which describes what is known as the "apache
request cycle."  what may not be clear from just reading that introduction
is that upon receiving a request, apache will step through that cycle and
look for some C module to handle each phase - it typically asks mod_perl
first, then goes on to other C modules (like mod_rewrite, mod_auth, or
mod_log_config).

in your case, when apache gets to the authen phase, it will first call
mod_perl, which will dispatch off to your PerlAuthenHandler.  likewise for
all the other phases _except_ the content generation phase, which has an
added bit of confusion in it :)  apache will call only the handler
designated by the SetHandler directive (or AddHandler, ScriptHandler, etc)
for the content generation phase (in 1.3 anyway - 2.0 is a bit different but
too confusing to explain here :)

so, to answer your question in a roundabout way, you can use mod_perl in any
and all phases and each will act independently of the others, allowing you
considerable freedom in how you control request activities.

HTH

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp1] multiple handlers?

Posted by Tony Clayton <to...@clayton.ca>.
Quoting Geoffrey Young <ge...@modperlcookbook.org>:

> using a PerlAuthenHandler in no way affects who can run in any other
> apache
> phase, such as fixups or (in your case) content generation.  well,
> outside
> of the normal duties of an authen handler, anyway :)

Geoff, 

Thanks for the great pointers.  The fact that Perl*Handler didn't rely
on "SetHandler perl-script" was the piece I was missing, and I only
doubted that because it just wasn't working the way I initially
expected. After
reading chapter 13 (http://www.modperlcookbook.org/chapters/ch13.pdf), I
realize that using the wrong Perl*Handler.  I really
wanted PerlAccessHandler, which does get called correctly in my setup.
I'm not actually authenticating users, but providing access control
based on headers, so I think this is what I want.

PerlAuthenHandler and PerlAuthzHandler weren't getting called from my
Location block, because I was not specifying "Require" or "Auth*"
directives.   

Anyway, I think I'm all set with PerlAccessHandler.  

Thanks,
Tony



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html