You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Rhett Creighton <rh...@creighton.com> on 2007/01/01 12:58:44 UTC
DirectoryIndex
I think that this is pretty import to add to the core features. I was
able to get the patch to work, but I had to add:
use Apache2::RequestUtil;
> **********
> mod_perl-1.99_16-3
> **********
> DirectoryIndex index.pl
please see this thread
http://marc.theaimsgroup.com/?t=111335099400001&r=1&w=2
specifically the solution found here
http://marc.theaimsgroup.com/?l=apache-modperl&m=111445150218566&w=2
if this keeps coming up I might consider adding the My::Fixup code to
mp2core as Apache2::DirectoryFixup like in the attached patch (with
documentation, of course :)
--Geoff
["dirindex.patch" (text/x-patch)]
Index: ModPerl-Registry/t/conf/extra.conf.in
===================================================================
--- ModPerl-Registry/t/conf/extra.conf.in (revision 292232)
+++ ModPerl-Registry/t/conf/extra.conf.in (working copy)
@@ -37,6 +37,7 @@
#############################
<IfModule mod_alias.c>
Alias /registry/ @ServerRoot@/cgi-bin/
+ Alias /dirindex/ @ServerRoot@/cgi-bin/
Alias /registry_bb/ @ServerRoot@/cgi-bin/
Alias /registry_oo_conf/ @ServerRoot@/cgi-bin/
Alias /registry_prefork/ @ServerRoot@/cgi-bin/
@@ -65,6 +66,18 @@
PerlOptions +ParseHeaders
</Location>
+PerlModule Apache2::DirectoryFixup
+<IfModule mod_dir.c>
+ <Location /dirindex>
+ SetHandler perl-script
+ Options +ExecCGI
+ PerlResponseHandler ModPerl::Registry
+ PerlOptions +ParseHeaders
+ DirectoryIndex cgi.pl
+ PerlFixupHandler Apache2::DirectoryFixup
+ </Location>
+</IfModule>
+
<Location /registry_modperl_handler>
SetHandler modperl
Options +ExecCGI
--- /dev/null 2005-09-29 04:34:53.321311760 -0400
+++ lib/Apache2/DirectoryFixup.pm 2005-09-30 00:11:08.800027265
-0400
@@ -0,0 +1,26 @@
+package Apache2::DirectoryFixup;
+
+use strict;
+use warnings FATAL => qw(all);
+
+use Apache2::Const -compile => qw(DIR_MAGIC_TYPE OK DECLINED);
+use Apache2::RequestRec;
+
+sub handler {
+
+ my $r = shift;
+
+ if ($r->handler eq 'perl-script' &&
+ -d $r->filename &&
+ $r->is_initial_req)
+ {
+ $r->handler(Apache2::Const::DIR_MAGIC_TYPE);
+
+ return Apache2::Const::OK;
+ }
+
+ return Apache2::Const::DECLINED;
+}
+
+1;
+
--- /dev/null 2005-09-29 04:34:53.321311760 -0400
+++ ModPerl-Registry/t/dirindex.t 2005-09-30 00:08:32.871526372
-0400
@@ -0,0 +1,20 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest qw(GET);
+
+plan tests => 2, need [qw(mod_alias.c HTML::HeadParser mod_dir.c)],
+ need_min_module_version CGI => 3.08;
+
+my $url = "/dirindex/";
+my $res = GET $url;
+
+ok t_cmp($res->header('Content-type'),
+ qr{^text/html},
+ "test Content-type header setting via DirectoryIndex");
+
+ok t_cmp(lc($res->content),
+ '<b>done</b>',
+ "test body via DirectoryIndex");