Apache-Dir
view release on metacpan or search on metacpan
lib/Apache/Dir.pm view on Meta::CPAN
package Apache::Dir;
$Apache::Dir::VERSION = '0.07';
# Define constants for compatibility with mod_perl 1 and mod_perl 2.
use constant DECLINED => -1;
use constant DIR_MAGIC_TYPE => 'httpd/unix-directory';
use constant HTTP_MOVED_PERMANENTLY => 301;
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;
}
#!/usr/bin/perl -w
use strict;
use Test::More tests => 9;
use constant DECLINED => -1;
use constant DIR_MAGIC_TYPE => 'httpd/unix-directory';
use constant HTTP_MOVED_PERMANENTLY => 301;
{
package Apache::FakeRequest;
no warnings 'redefine';
sub new {
my $class = shift;
bless { @_ } => $class;
}
sub content_type { shift->{content_type} }
( run in 2.971 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )