Matt Sergeant wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> This is just a heads up on something I've not seen documented in either the
> Eagle book or in the Cookbook (at least not that I can find).
>
> If you create a subrequest via $r->lookup_file(), the per_dir_config entry
> doesn't seem to be created. If you use $r->lookup_uri(), it's fine. This can
> be an issue for people with complex applications and configurations trying to
> find out why $sub->dir_config() might not be returning what they expect.
>
> Took me a while to figure this one out - just thought others might like to
> know.
well, I hadn't thought about it until now, but actually that makes sense to me (as
it's
early in the morning here :)
mod_perl just uses r->per_dir_config for $r->dir_config, so it's relying on Apache's
merging behavior wrt lookup_file() and lookup_uri(). one of the things that
lookup_uri()
does that lookup_file() does not do is call location_walk, which merges per-directory
configs.
I think this makes sense, since a single file can be served by multiple <Location>
containers, and with lookup_file() you're essentially telling Apache that you already
know
the filename (sans the translation phase) and you don't really need to know how it
relates
to the incoming URI. both lookup_file() and lookup_uri() call the <File> and
<Directory>
merging routines, so I would expect that calling lookup_file() on files governed by
those
directives would merge just fine.
actually, I ran the below test against my perl-bin/ and cgi-bin/ setups (where
perl-bin is
a <Location> + Alias and cgi-bin is a <Directory> + ScriptAlias) and it works as I
suspected.
does this help?
--Geoff
use Apache::Constants qw(OK);
use strict;
my $r = shift;
#my $sub = $r->lookup_file('/usr/local/apache/perl-bin/env.pl');
my $sub = $r->lookup_uri('/perl-bin/env.pl');
$r->send_http_header('text/plain');
print $r->uri, ":\n";
$sub->dir_config->do(sub {
my ($field, $value) = @_;
print "$field => $value\n";
1;
});
return OK;