You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jay Buffington <ja...@mlug.missouri.edu> on 2001/08/08 09:44:33 UTC

Using PerlTypeHandler and PerlHandler for the same

Hi,

In my httpd.conf file I have: 
<Location /foo/>
    SetHandler perl-script
    PerlTypeHandler foo
    PerlHandler bar
</Location>

and then in the foo and bar files I have: 

----------file foo.pm---------
package foo;

sub handler {
    my $r = shift;

    $r->log_error("I'm in foo.");
}
1;


----------file bar.pm---------
package bar; 

sub handler {
    my $r = shift;

    $r->log_error("I'm in bar.");
}
1;


I would expect this experiment would print out "I'm in foo." followed by "I'm in bar." to my apache error log.  It only prints "I'm in foo."  If I remove the PerlTypeHandler line from the httpd.conf I get only "I'm in bar."  If I leave the TypeHandler but omit the PerlHandler, and add $r->push_handlers(PerlHandler=>\&bar::handler); to foo.pm I still only get "I'm in foo."

I'm using Perl 5.6 and mod_perl 1.25 with apache 1.3.19 

Why does this not work as I expected?

Thanks.
Jay Buffington

Re: Using PerlTypeHandler and PerlHandler for the same

Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 8 Aug 2001, Jay Buffington wrote:

> Hi,
> 
> In my httpd.conf file I have: 
> <Location /foo/>
>     SetHandler perl-script
>     PerlTypeHandler foo
>     PerlHandler bar
> </Location>
> 
> and then in the foo and bar files I have: 
> 
> ----------file foo.pm---------
> package foo;
> 
> sub handler {
>     my $r = shift;
> 
>     $r->log_error("I'm in foo.");
> }
> 1;
> 
> 
> ----------file bar.pm---------
> package bar; 
> 
> sub handler {
>     my $r = shift;
> 
>     $r->log_error("I'm in bar.");
> }
> 1;
> 
> 
> I would expect this experiment would print out "I'm in foo." followed by "I'm in bar." to my apache error log.  It only prints "I'm in foo."  If I remove the PerlTypeHandler line from the httpd.conf I get only "I'm in bar."  If I leave the TypeHandler but omit the PerlHandler, and add $r->push_handlers(PerlHandler=>\&bar::handler); to foo.pm I still only get "I'm in foo."
> 
> I'm using Perl 5.6 and mod_perl 1.25 with apache 1.3.19 
> 
> Why does this not work as I expected?

because your PerlTypeHandler has returned the value 0 (aka OK), the type
handler phase is 'run first' (stop at first to return anything other than
DECLINED), which means mod_mime's type handler is never run so
r->handler never gets configured.  you either need to return DECLINED in
your PerlTypeHandler or set $r->handler('perl-script') yourself.