Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by maverick (Curate)
on Feb 26, 2002 at 20:40 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://147718]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-26 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found