9 # mod_rewrite to app root for non / based app
12 REDIRECT_URL => '/comics/',
13 SCRIPT_NAME => '/comics/dispatch.cgi',
14 REQUEST_URI => '/comics/',
16 is ''.$r->uri, 'http://www.foo.com/comics/';
17 is ''.$r->base, 'http://www.foo.com/comics/';
20 # mod_rewrite to sub path under app root for non / based app
23 PATH_INFO => '/foo/bar.gif',
24 REDIRECT_URL => '/comics/foo/bar.gif',
25 SCRIPT_NAME => '/comics/dispatch.cgi',
26 REQUEST_URI => '/comics/foo/bar.gif',
28 is ''.$r->uri, 'http://www.foo.com/comics/foo/bar.gif';
29 is ''.$r->base, 'http://www.foo.com/comics/';
32 # Standard CGI hit for non / based app
35 PATH_INFO => '/static/css/blueprint/screen.css',
36 SCRIPT_NAME => '/~bobtfish/Gitalist/script/gitalist.cgi',
37 REQUEST_URI => '/~bobtfish/Gitalist/script/gitalist.cgi/static/css/blueprint/screen.css',
39 is ''.$r->uri, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/static/css/blueprint/screen.css';
40 is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/';
42 # / %2F %252F escaping case.
45 PATH_INFO => '/%2F/%2F',
46 SCRIPT_NAME => '/~bobtfish/Gitalist/script/gitalist.cgi',
47 REQUEST_URI => '/~bobtfish/Gitalist/script/gitalist.cgi/%252F/%252F',
49 is ''.$r->uri, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/%252F/%252F';
50 is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/';
53 # Using rewrite rules to ask for a sub-path in your app.
54 # E.g. RewriteRule ^(.*)$ /path/to/fastcgi/domainprofi.fcgi/iframeredirect$1 [L,NS]
57 PATH_INFO => '/iframeredirect/info',
59 REQUEST_URI => '/info',
61 is ''.$r->uri, 'http://www.foo.com/iframeredirect/info';
62 is ''.$r->base, 'http://www.foo.com/';
65 # nginx example from espent with path /"foo"
70 REQUEST_URI => '/%22foo%22',
72 is ''.$r->path, '%22foo%22';
73 is ''.$r->uri, 'http://www.foo.com/%22foo%22';
74 is ''.$r->base, 'http://www.foo.com/';
77 # nginx example from espent with path /"foo" and the app based at /oslobilder
80 PATH_INFO => 'oslobilder/"foo"',
81 SCRIPT_NAME => '/oslobilder/',
82 REQUEST_URI => '/oslobilder/%22foo%22',
84 is ''.$r->path, '%22foo%22', 'path correct';
85 is ''.$r->uri, 'http://www.foo.com/oslobilder/%22foo%22', 'uri correct';
86 is ''.$r->base, 'http://www.foo.com/oslobilder/', 'base correct';
90 PATH_INFO => '/auth/login',
92 REQUEST_URI => '/login',
94 is ''.$r->path, 'auth/login', 'path correct';
95 is ''.$r->uri, 'http://www.foo.com/tx/auth/login', 'uri correct';
96 is ''.$r->base, 'http://www.foo.com/tx/', 'base correct';
99 # test req->base and c->uri_for work correctly after an internally redirected request
100 # (i.e. REDIRECT_URL set) when the PATH_INFO contains a regex
102 my $path = '/engine/request/uri/Rx(here)';
106 REQUEST_URI => $path,
107 REDIRECT_URL => $path,
110 is $r->path, 'engine/request/uri/Rx(here)', 'URI contains correct path';
111 is $r->base, 'http://www.foo.com/', 'Base is correct';
115 # FIXME - Test proxy logic
116 # - Test query string
117 # - Test non standard port numbers
118 # - Test // in PATH_INFO
119 # - Test scheme (secure request on port 80)
122 my $use_request_uri_for_path = shift;
125 HTTP_HOST => 'www.foo.com',
129 my $engine = Catalyst::Engine->new(
130 env => { %template, @_ },
132 my $i = TestApp->new;
133 $i->setup_finished(0);
134 $i->config(use_request_uri_for_path => $use_request_uri_for_path);
135 $i->setup_finished(1);
136 $engine->prepare_path($i);