perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [mp2] Declining from response handler bypasses other handlers
Date Thu, 02 Oct 2003 14:57:25 GMT

My suggestion are:

1.    print $requested_dir; to see what you got.

2 changing your code
return Apache::DECLINED unless exists $protected_dirs{$requested_dir};
return Apache::DECLINED if $protected_dirs{$requested_dir};

Hope it helpful.


                      Westcott"                To:         
                      <matthew@torchbox        cc:                                    
                      .com>                    Subject:  [mp2] Declining from response
handler bypasses other handlers                 
                      10/02/2003 08:47                                                   

I'm using a PerlResponseHandler to control access to selected
directories of a site, and I've encountered a similar problem to that
described in
where returning a 'declined' status is skipping other handlers and
going straight to Apache's default handler.

My code is:

package MyApache::Permissions;

use strict;
use warnings;
use Apache::RequestRec ();
use Apache::Const -compile => qw(OK DECLINED);

my %protected_dirs = (
             'foo' => 1,
             'bar/baz' => 1,

sub handler {
        my $r = shift;

        my $requested_dir = $r->filename;
        $requested_dir =~ s|^/home/www/html/my_site/(.*)/[^\/]*$|$1|;

        return Apache::DECLINED unless exists $protected_dirs

        print "mod_perl has taken over the $requested_dir directory...\n";

        return Apache::OK;

and this is active over the whole site, using these directives in
<Location />
        SetHandler perl-script
        PerlResponseHandler MyApache::Permissions

Blocking the named directories works fine, but for the unblocked
directories (the ones for which I return Apache::DECLINED) the
existing (non-Perl) response handlers aren't taking effect, so my
ColdFusion scripts are being sent through unparsed, and directory
indexes no longer work (/something/index.html works, /something/
returns a 404).

I suspect the problem is on the Apache side; the SetHandler is
overriding all other handlers. Is there any way around this?

I'm using Apache/2.0.47 and mod_perl/1.99_10, on Linux.

- Matthew

View raw message