[Catalyst-commits] r6362 - in trunk/Catalyst-Engine-Apache: .
lib/Catalyst/Engine t/conf t/optional
andyg at dev.catalyst.perl.org
andyg at dev.catalyst.perl.org
Thu May 3 22:53:29 GMT 2007
Author: andyg
Date: 2007-05-03 22:53:28 +0100 (Thu, 03 May 2007)
New Revision: 6362
Added:
trunk/Catalyst-Engine-Apache/t/optional/mod_perl-locationmatch.pl
Modified:
trunk/Catalyst-Engine-Apache/Changes
trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
trunk/Catalyst-Engine-Apache/t/conf/extra.conf.in
Log:
Apache: Added support for LocationMatch blocks
Modified: trunk/Catalyst-Engine-Apache/Changes
===================================================================
--- trunk/Catalyst-Engine-Apache/Changes 2007-05-03 15:05:46 UTC (rev 6361)
+++ trunk/Catalyst-Engine-Apache/Changes 2007-05-03 21:53:28 UTC (rev 6362)
@@ -1,10 +1,11 @@
This file documents the revision history for Catalyst::Engine::Apache.
1.10
+ - Properly detect the base when running within a LocationMatch block.
- Use the unparsed URI for building the path instead of Apache's
pre-parsed URI.
- Load APR::Table when using mod_perl 1.99.
- - Switch to Module::Install
+ - Switch to Module::Install.
1.09 2007-03-28 23:00:00
- Fixed compatibility with older Catalyst versions. 5.7008+
Modified: trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
===================================================================
--- trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm 2007-05-03 15:05:46 UTC (rev 6361)
+++ trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm 2007-05-03 21:53:28 UTC (rev 6362)
@@ -112,16 +112,6 @@
$base_path = $location;
}
- # base must end in a slash
- $base_path .= '/' unless $base_path =~ m{/$};
-
- # Are we an Apache::Registry script? Why anyone would ever want to run
- # this way is beyond me, but we'll support it!
- # XXX: This needs a test
- if ( defined $ENV{SCRIPT_NAME} && $self->apache->filename && -f $self->apache->filename && -x _ ) {
- $base_path .= $ENV{SCRIPT_NAME};
- }
-
# Using URI directly is way too slow, so we construct the URLs manually
my $uri_class = "URI::$scheme";
@@ -142,9 +132,30 @@
($path, $qs) = split /\?/, $path_query, 2;
}
+ # Check if $base_path appears to be a regex,
+ # meaning we're in a LocationMatch block
+ if ( $base_path =~ m{[^A-Za-z/]} ) {
+ # Find out what part of the URI path matches the LocationMatch regex,
+ # that will become our base
+ my $match = qr/($base_path)/;
+ my ($base_match) = $path =~ $match;
+
+ $base_path = $base_match;
+ }
+
# Strip leading slash
$path =~ s{^/+}{};
+ # base must end in a slash
+ $base_path .= '/' unless $base_path =~ m{/$};
+
+ # Are we an Apache::Registry script? Why anyone would ever want to run
+ # this way is beyond me, but we'll support it!
+ # XXX: This needs a test
+ if ( defined $ENV{SCRIPT_NAME} && $self->apache->filename && -f $self->apache->filename && -x _ ) {
+ $base_path .= $ENV{SCRIPT_NAME};
+ }
+
# If the path is contained within the base, we need to make the path
# match base. This handles the case where the app is running at /deep/path
# but a request to /deep/path fails where /deep/path/ does not.
Modified: trunk/Catalyst-Engine-Apache/t/conf/extra.conf.in
===================================================================
--- trunk/Catalyst-Engine-Apache/t/conf/extra.conf.in 2007-05-03 15:05:46 UTC (rev 6361)
+++ trunk/Catalyst-Engine-Apache/t/conf/extra.conf.in 2007-05-03 21:53:28 UTC (rev 6362)
@@ -42,6 +42,12 @@
PerlResponseHandler TestApp
</Location>
+ # test LocationMatch (RT 26921)
+ <LocationMatch ^/match/(this|that)*>
+ SetHandler modperl
+ PerlResponseHandler TestApp
+ </LocationMatch>
+
# test using the perl-script handler
<Location /oldscript>
SetHandler perl-script
Added: trunk/Catalyst-Engine-Apache/t/optional/mod_perl-locationmatch.pl
===================================================================
--- trunk/Catalyst-Engine-Apache/t/optional/mod_perl-locationmatch.pl (rev 0)
+++ trunk/Catalyst-Engine-Apache/t/optional/mod_perl-locationmatch.pl 2007-05-03 21:53:28 UTC (rev 6362)
@@ -0,0 +1,24 @@
+#!perl
+
+# Run all tests against Apache mod_perl using a LocationMatch regex block
+#
+# Note, to get this to run properly, you may need to give it the path to your
+# httpd.conf:
+#
+# perl t/optional/mod_perl-locationmatch.pl -httpd_conf /etc/apache/httpd.conf
+#
+# For debugging, you can start TestApp and leave it running with
+# perl t/optional/mod_perl-locationmatch.pl -httpd_conf /etc/apache/httpd.conf --start-httpd
+#
+# To stop it:
+# perl t/optional/mod_perl-locationmatch.pl -httpd_conf /etc/apache/httpd.conf --stop-httpd
+
+use strict;
+use warnings;
+
+use Apache::Test;
+use Apache::TestRunPerl ();
+
+$ENV{CATALYST_SERVER} = 'http://localhost:8529/match/that';
+
+Apache::TestRunPerl->new->run(@ARGV);
Property changes on: trunk/Catalyst-Engine-Apache/t/optional/mod_perl-locationmatch.pl
___________________________________________________________________
Name: svn:executable
+ *
More information about the Catalyst-commits
mailing list