[Catalyst-commits] r12279 - in Catalyst-Runtime/5.80/trunk: .
lib/Catalyst/Engine t/aggregate
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Dec 9 20:54:53 GMT 2009
Author: t0m
Date: 2009-12-09 20:54:53 +0000 (Wed, 09 Dec 2009)
New Revision: 12279
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm
Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_engine_cgi-prepare_path.t
Log:
More tests for the prepare_path thing, fix said tests, changelog
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2009-12-09 20:50:18 UTC (rev 12278)
+++ Catalyst-Runtime/5.80/trunk/Changes 2009-12-09 20:54:53 UTC (rev 12279)
@@ -9,6 +9,10 @@
than listening on all interfaces, which was the previous default. (Dave
Rolsky)
- Fix the script environment variables MYAPP_PORT and MYAPP_RELOAD RT#52604
+ - Fix aliasing applications under non-root paths with mod_rewrite in
+ some apache versions where %ENV{SCRIPT_NAME} is set to the real name of
+ the script, by using $ENV{REDIRECT_URL} which contains the non-rewritten
+ URI.
New features:
- The __MOP__ hash element is suppressed from being dumped fully
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm 2009-12-09 20:50:18 UTC (rev 12278)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm 2009-12-09 20:54:53 UTC (rev 12279)
@@ -108,6 +108,8 @@
=cut
+# Please don't touch this method without adding tests in
+# t/aggregate/unit_core_engine_cgi-prepare_path.t
sub prepare_path {
my ( $self, $c ) = @_;
local (*ENV) = $self->env || \%ENV;
@@ -153,9 +155,7 @@
# Here we try to resurrect the original encoded URI from REQUEST_URI.
my $path_info = $ENV{PATH_INFO};
if (my $req_uri = $ENV{REQUEST_URI}) {
- if (defined $script_name) {
- $req_uri =~ s/^\Q$script_name\E//;
- }
+ $req_uri =~ s/^\Q$base_path\E//;
$req_uri =~ s/\?.*$//;
$path_info = $req_uri if $req_uri;
}
Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_engine_cgi-prepare_path.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_engine_cgi-prepare_path.t 2009-12-09 20:50:18 UTC (rev 12278)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_engine_cgi-prepare_path.t 2009-12-09 20:54:53 UTC (rev 12279)
@@ -6,19 +6,58 @@
use TestApp;
use Catalyst::Engine::CGI;
+my %template = (
+ HTTP_HOST => 'www.foo.com',
+ PATH_INFO => '/',
+);
+
+# mod_rewrite to app root for non / based app
{
- our %ENV = (
- HTTP_HOST => 'www.foo.com',
+ my $r = get_req (
REDIRECT_URL => '/comics/',
- PATH_INFO => '/',
SCRIPT_NAME => '/comics/dispatch.cgi',
REQUEST_URI => '/comics/',
);
+ is ''.$r->uri, 'http://www.foo.com/comics/';
+ is ''.$r->base, 'http://www.foo.com/comics/';
+}
+
+# mod_rewrite to sub path under app root for non / based app
+{
+ my $r = get_req (
+ PATH_INFO => '/foo/bar.gif',
+ REDIRECT_URL => '/comics/foo/bar.gif',
+ SCRIPT_NAME => '/comics/dispatch.cgi',
+ REQUEST_URI => '/comics/foo/bar.gif',
+ );
+ is ''.$r->uri, 'http://www.foo.com/comics/foo/bar.gif';
+ is ''.$r->base, 'http://www.foo.com/comics/';
+}
+
+# Standard CGI hit for non / based app
+{
+ my $r = get_req (
+ PATH_INFO => '/static/css/blueprint/screen.css',
+ SCRIPT_NAME => '/~bobtfish/Gitalist/script/gitalist.cgi',
+ REQUEST_URI => '/~bobtfish/Gitalist/script/gitalist.cgi/static/css/blueprint/screen.css',
+ );
+ is ''.$r->uri, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/static/css/blueprint/screen.css';
+ is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/';
+}
+
+# FIXME - Test proxy logic
+# - Test encoding/escaping
+# - Test query string
+# - Test non standard port numbers
+# - Test // in PATH_INFO
+# - Test scheme (secure request on port 80)
+
+sub get_req {
+ local %ENV = (%template, @_);
my $i = TestApp->new;
$i->engine(Catalyst::Engine::CGI->new);
$i->engine->prepare_path($i);
- is ''.$i->req->uri, 'http://www.foo.com/comics/';
- is ''.$i->req->base, 'http://www.foo.com/comics/';
+ return $i->req;
}
done_testing;
More information about the Catalyst-commits
mailing list