Re: Inconsistency with dhandlers

David Wheeler <[email protected]>
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
On May 11, 2004, at 2:05 PM, David Wheeler wrote:

>> One thought, you might want to mention in the docs that this module
>> shouldn't be necessary in 2.0.  I bet there's a way to stack mod_dir 
>> with
>> a Perl handler in 2.0.  Maybe ask about it on the MP list, since I bet
>> Geoff Young would know how to do it.
>
> Good point. I'll email the mod_perl developers to ask about this.

Actually, it can be done with Apache 1 using ClearModules and 
AddModule, to give mod_dir higher priority than mod_perl. I'll write up 
a FAQ answer for this when I'm clear on how to get it all to work for 
mod_perl 2.

In the meantime, I've released Apache::Dir on CPAN. This is all that it 
is:

package Apache::Dir;

use Apache::Constants qw(DECLINED DIR_MAGIC_TYPE 
HTTP_MOVED_PERMANENTLY);

$Apache::Dir::VERSION = '0.02';

sub handler {
     my $r = shift;
     return DECLINED unless $r->content_type eq DIR_MAGIC_TYPE
       && $r->uri !~ m{/$};
     my $args = $r->args;
     $r->header_out(Location => $r->uri . '/' . ($args ? "?$args" : ''));
     return HTTP_MOVED_PERMANENTLY;
}

Note the use of the DIR_MAGIC_TYPE constant. That's the quickest way to 
tell if it's a directory. Cache that away in your thoughts for when you 
get Mason 1.3 to decline such requests.

Regards,

David



-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.