7 use Catalyst::Engine::CGI;
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/', 'uri is correct';
17 is ''.$r->base, 'http://www.foo.com/comics/', 'base is correct';
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', 'uri correct';
50 is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/', 'base correct';
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 local $TODO = 'Another mod_rewrite case';
92 PATH_INFO => '/auth/login',
94 REQUEST_URI => '/login',
96 is ''.$r->path, 'auth/login', 'path correct';
97 is ''.$r->uri, 'http://www.foo.com/tx/auth/login', 'uri correct';
98 is ''.$r->base, 'http://www.foo.com/tx/', 'base correct';
101 # test req->base and c->uri_for work correctly after an internally redirected request
102 # (i.e. REDIRECT_URL set) when the PATH_INFO contains a regex
104 my $path = '/engine/request/uri/Rx(here)';
108 REQUEST_URI => $path,
109 REDIRECT_URL => $path,
112 is $r->path, 'engine/request/uri/Rx(here)', 'URI contains correct path';
113 is $r->base, 'http://www.foo.com/', 'Base is correct';
117 # FIXME - Test proxy logic
118 # - Test query string
119 # - Test non standard port numbers
120 # - Test // in PATH_INFO
121 # - Test scheme (secure request on port 80)
125 HTTP_HOST => 'www.foo.com',
129 local %ENV = (%template, @_);
131 my $i = TestApp->new;
132 $i->engine(Catalyst::Engine::CGI->new);
133 $i->engine->prepare_path($i);