[Catalyst-commits] r13309 - in Catalyst-Runtime/5.80/branches/psgi:
. lib/Catalyst t/aggregate
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Mon May 24 15:44:08 GMT 2010
Author: t0m
Date: 2010-05-24 16:44:08 +0100 (Mon, 24 May 2010)
New Revision: 13309
Modified:
Catalyst-Runtime/5.80/branches/psgi/
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm
Catalyst-Runtime/5.80/branches/psgi/t/aggregate/unit_core_engine-prepare_path.t
Log:
r15604 at spaceinvaders: t0m | 2010-05-23 13:14:32 +0100
Start making the path handling like it is in trunk. Merge extra tests, add using PATH_INFO. Doesn't yet work in all the cases I expect it to and I don't quite understand why yet
Property changes on: Catalyst-Runtime/5.80/branches/psgi
___________________________________________________________________
Modified: svk:merge
- 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/aggregate_more:11803
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/better_scripts:12074
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/disable_regex_fallback:11456
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_path_info_decoding:12089
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_request_uri:13262
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/index_default_fuckage:10646
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/more_metaclass_compat:13280
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/namespace_handling_refactor:10655
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/param_filtering:13012
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_encode_captures_andor_args_take2:11811
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_for_utf8:12834
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/trunk:13297
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-better_scripts:11331
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-mech_tests:15583
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-psgi:15603
8a9521aa-ff93-41d6-9f87-b05cafcdab40:/local/cat/Catalyst-Runtime/5.80/trunk:8157
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
+ 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/aggregate_more:11803
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/better_scripts:12074
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/disable_regex_fallback:11456
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_path_info_decoding:12089
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_request_uri:13262
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/index_default_fuckage:10646
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/more_metaclass_compat:13280
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/namespace_handling_refactor:10655
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/param_filtering:13012
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_encode_captures_andor_args_take2:11811
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_for_utf8:12834
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/trunk:13297
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-better_scripts:11331
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-mech_tests:15583
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-psgi:15604
8a9521aa-ff93-41d6-9f87-b05cafcdab40:/local/cat/Catalyst-Runtime/5.80/trunk:8157
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
Modified: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm 2010-05-24 15:44:06 UTC (rev 13308)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm 2010-05-24 15:44:08 UTC (rev 13309)
@@ -523,10 +523,19 @@
my $base_path = $env->{SCRIPT_NAME} || "/";
# set the request URI
- my $req_uri = $env->{REQUEST_URI};
- $req_uri =~ s/\?.*$//;
- my $path = $req_uri;
- $path =~ s{^/+}{};
+ my $path;
+ if (!$ctx->config->{use_request_uri_for_path}) {
+ $path = $base_path . $env->{PATH_INFO};
+ $path =~ s{^/+}{};
+ $path =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
+ $path =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE
+ }
+ else {
+ my $req_uri = $env->{REQUEST_URI};
+ $req_uri =~ s/\?.*$//;
+ $path = $req_uri;
+ $path =~ s{^/+}{};
+ }
# Using URI directly is way too slow, so we construct the URLs manually
my $uri_class = "URI::$scheme";
Modified: Catalyst-Runtime/5.80/branches/psgi/t/aggregate/unit_core_engine-prepare_path.t
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/t/aggregate/unit_core_engine-prepare_path.t 2010-05-24 15:44:06 UTC (rev 13308)
+++ Catalyst-Runtime/5.80/branches/psgi/t/aggregate/unit_core_engine-prepare_path.t 2010-05-24 15:44:08 UTC (rev 13309)
@@ -8,7 +8,7 @@
# mod_rewrite to app root for non / based app
{
- my $r = get_req (
+ my $r = get_req (0,
SCRIPT_NAME => '/comics/dispatch.cgi',
REQUEST_URI => '/comics/',
);
@@ -18,7 +18,7 @@
# mod_rewrite to sub path under app root for non / based app
{
- my $r = get_req (
+ my $r = get_req (0,
PATH_INFO => '/foo/bar.gif',
SCRIPT_NAME => '/comics/dispatch.cgi',
REQUEST_URI => '/comics/foo/bar.gif',
@@ -29,7 +29,7 @@
# Standard CGI hit for non / based app
{
- my $r = get_req (
+ my $r = get_req (0,
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',
@@ -39,7 +39,7 @@
}
# / %2F %252F escaping case.
{
- my $r = get_req (
+ my $r = get_req (1,
PATH_INFO => '/%2F/%2F',
SCRIPT_NAME => '/~bobtfish/Gitalist/script/gitalist.cgi',
REQUEST_URI => '/~bobtfish/Gitalist/script/gitalist.cgi/%252F/%252F',
@@ -51,7 +51,7 @@
# Using rewrite rules to ask for a sub-path in your app.
# E.g. RewriteRule ^(.*)$ /path/to/fastcgi/domainprofi.fcgi/iframeredirect$1 [L,NS]
{
- my $r = get_req (
+ my $r = get_req (0,
PATH_INFO => '/iframeredirect/info',
SCRIPT_NAME => '',
REQUEST_URI => '/info',
@@ -60,8 +60,57 @@
is ''.$r->base, 'http://www.foo.com/';
}
+# nginx example from espent with path /"foo"
+{
+ my $r = get_req (0,
+ PATH_INFO => '"foo"',
+ SCRIPT_NAME => '/',
+ REQUEST_URI => '/%22foo%22',
+ );
+ is ''.$r->path, '%22foo%22';
+ is ''.$r->uri, 'http://www.foo.com/%22foo%22';
+ is ''.$r->base, 'http://www.foo.com/';
+}
+# nginx example from espent with path /"foo" and the app based at /oslobilder
+{
+ my $r = get_req (1,
+ PATH_INFO => 'oslobilder/"foo"',
+ SCRIPT_NAME => '/oslobilder/',
+ REQUEST_URI => '/oslobilder/%22foo%22',
+ );
+ is ''.$r->path, '%22foo%22', 'path correct';
+ is ''.$r->uri, 'http://www.foo.com/oslobilder/%22foo%22', 'uri correct';
+ is ''.$r->base, 'http://www.foo.com/oslobilder/', 'base correct';
+}
+{
+ local $TODO = 'Another mod_rewrite case';
+ my $r = get_req (0,
+ PATH_INFO => '/auth/login',
+ SCRIPT_NAME => '/tx',
+ REQUEST_URI => '/login',
+ );
+ is ''.$r->path, 'auth/login', 'path correct';
+ is ''.$r->uri, 'http://www.foo.com/tx/auth/login', 'uri correct';
+ is ''.$r->base, 'http://www.foo.com/tx/', 'base correct';
+}
+# test req->base and c->uri_for work correctly after an internally redirected request
+# (i.e. REDIRECT_URL set) when the PATH_INFO contains a regex
+{
+ my $path = '/engine/request/uri/Rx(here)';
+ my $r = get_req (0,
+ SCRIPT_NAME => '/',
+ PATH_INFO => $path,
+ REQUEST_URI => $path,
+ REDIRECT_URL => $path,
+ );
+
+ is $r->path, 'engine/request/uri/Rx(here)', 'URI contains correct path';
+ is $r->base, 'http://www.foo.com/', 'Base is correct';
+}
+
+
# FIXME - Test proxy logic
# - Test query string
# - Test non standard port numbers
@@ -69,6 +118,8 @@
# - Test scheme (secure request on port 80)
sub get_req {
+ my $use_request_uri_for_path = shift;
+
my %template = (
HTTP_HOST => 'www.foo.com',
PATH_INFO => '/',
@@ -78,6 +129,9 @@
env => { %template, @_ },
);
my $i = TestApp->new;
+ $i->setup_finished(0);
+ $i->config(use_request_uri_for_path => $use_request_uri_for_path);
+ $i->setup_finished(1);
$engine->prepare_path($i);
return $i->req;
}
More information about the Catalyst-commits
mailing list