Commit | Line | Data |
fbcc39ad |
1 | package TestApp::Controller::Engine::Request::URI;\r |
2 | \r |
3 | use strict;\r |
4 | use base 'Catalyst::Base';\r |
5 | \r |
6 | sub default : Private {\r |
7 | my ( $self, $c ) = @_;\r |
8 | \r |
9 | $c->forward('TestApp::View::Dump::Request');\r |
10 | }\r |
11 | \r |
12 | sub change_path : Local {\r |
13 | my ( $self, $c ) = @_;\r |
14 | \r |
15 | # change the path\r |
16 | $c->req->path( '/my/app/lives/here' );\r |
17 | \r |
18 | $c->forward('TestApp::View::Dump::Request');\r |
19 | }\r |
20 | \r |
21 | sub change_base : Local {\r |
22 | my ( $self, $c ) = @_;\r |
23 | \r |
24 | # change the base and uri paths\r |
25 | $c->req->base->path( '/new/location' );\r |
26 | $c->req->uri->path( '/new/location/engine/request/uri/change_base' );\r |
27 | \r |
28 | $c->forward('TestApp::View::Dump::Request');\r |
29 | }\r |
30 | \r |
bd917b94 |
31 | sub uri_with : Local {\r |
32 | my ( $self, $c ) = @_;\r |
33 | \r |
34 | # change the current uri\r |
35 | my $uri = $c->req->uri_with( { b => 1 } );\r |
36 | my %query = $uri->query_form;\r |
37 | \r |
38 | $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );\r |
39 | $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );\r |
40 | \r |
41 | $c->forward('TestApp::View::Dump::Request');\r |
42 | }\r |
43 | \r |
fbb513f7 |
44 | sub uri_with_object : Local {\r |
45 | my ( $self, $c ) = @_;\r |
46 | \r |
47 | my $uri = $c->req->uri_with( { a => $c->req->base } );\r |
48 | my %query = $uri->query_form;\r |
49 | \r |
50 | $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );\r |
51 | \r |
52 | $c->forward('TestApp::View::Dump::Request');\r |
53 | }\r |
54 | \r |
5789a3d8 |
55 | sub uri_with_utf8 : Local {\r |
56 | my ( $self, $c ) = @_;\r |
57 | \r |
58 | # change the current uri\r |
59 | my $uri = $c->req->uri_with( { unicode => "\x{2620}" } );\r |
60 | \r |
61 | $c->res->header( 'X-Catalyst-uri-with' => "$uri" );\r |
62 | \r |
63 | $c->forward('TestApp::View::Dump::Request');\r |
64 | }\r |
65 | \r |
d0f0fcf6 |
66 | sub uri_with_undef : Local {\r |
67 | my ( $self, $c ) = @_;\r |
68 | |
69 | my $warnings = 0; |
70 | local $SIG{__WARN__} = sub { $warnings++ };\r |
71 | \r |
72 | # change the current uri |
73 | my $uri = $c->req->uri_with( { foo => undef } );\r |
74 | \r |
75 | $c->res->header( 'X-Catalyst-warnings' => $warnings );\r |
76 | \r |
77 | $c->forward('TestApp::View::Dump::Request');\r |
78 | }\r |
79 | \r |
fbcc39ad |
80 | 1;\r |