Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

DECLINED from mod_perl doesn't work quite like I expect...

by maverick (Curate)
on Feb 26, 2002 at 20:40 UTC ( #147718=perlquestion: print w/replies, xml ) Need Help??
maverick has asked for the wisdom of the Perl Monks concerning the following question:

Here's one for the mod_perl monks... Basically the problem I've run into is that returning DECLINED from a handler doesn't completely return you to the 'normal' chain of events in Apache like it is supposed to (and as the 'Apache Modules' book seems to agree). If I have a handler that looks like
package myHandler; use strict; use Apache; use Apache::Constants wq(:response); sub handler { my $r = shift; my $uri = $r->uri(); unless ($uri =~ /\.extension$/) { return DECLINED; } # rest of code
and a httpd.conf block like
<Directory "/usr/local/apache/sites/test"> SetHandler perl-script PerlHandler myHandler Options Indexes Includes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
I can't also have something like a PHP page in that same directory. PHP will be handled correctly in other directories, but will return the source for the page in this one. Granted I don't use PHP, but I'm trying to make this 'place nice with others'. Even stranger, if I add in a "ErrorDocument 404 /404.html" directive to that block, and access a page that doesn't exist, the connection just instantly closes.
[root@styx conf]# telnet localhost 80 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /test/you_are_not_here HTTP/1.0 Connection closed by foreign host.
I can get around this by using a 'Files ~' directive in the httpd.conf to match only my extension, but it seems like declining should work.

According to Writing Apache Modules pg 68. "The handler has decided it doesn't want to handle the request. Apache will act as if the subroutine were never called and either handle the phase internally or pass the request on to another module that has expressed its interest."

What am I missing here?

/\/\averick
perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

Replies are listed 'Best First'.
Re: DECLINED from mod_perl doesn't work quite like I expect...
by Matts (Deacon) on Feb 27, 2002 at 09:21 UTC
    The SetHandler directive basically overrides PHP's use of AddHandler. The only "handler" mod_perl will return you back to is "default-handler" - i.e. deliver the file as-is.

    A work around is to either use AddHandler perl-script .pl (or whatever extension you choose), or put all your PHP scripts elsewhere, or use <Files> to map your mod_perl bits, or use a PerlTypeHandler, as documented in the book (see the beginning of Chapter 4, or Chapter 8's "Reimplementing mod_mime..." section), to automatically re-map to PHP.

    Hope that helps.

      The files technique will work for php, but the one that really got me was the ErrorDocument directive not working.

      I guess I really wanted declined to work a little differently.

      Thanks...

      /\/\averick
      perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://147718]
Approved by root
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2018-02-20 16:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (271 votes). Check out past polls.

    Notices?