1 package TestApp::Controller::Engine::Request::URI;
4 use base 'Catalyst::Controller';
6 sub default : Private {
9 $c->forward('TestApp::View::Dump::Request');
12 sub change_path : Local {
13 my ( $self, $c ) = @_;
16 $c->req->path( '/my/app/lives/here' );
18 $c->forward('TestApp::View::Dump::Request');
21 sub change_base : Local {
22 my ( $self, $c ) = @_;
24 # change the base and uri paths
25 $c->req->base->path( '/new/location' );
26 $c->req->uri->path( '/new/location/engine/request/uri/change_base' );
28 $c->forward('TestApp::View::Dump::Request');
31 sub uri_with : Local {
32 my ( $self, $c ) = @_;
34 # change the current uri
35 my $uri = $c->req->uri_with( { b => 1, c => undef } );
36 my %query = $uri->query_form;
38 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
39 $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );
40 $c->res->header( 'X-Catalyst-Param-c' => exists($query{ c }) ? $query{ c } : '--notexists--' );
41 $c->res->header( 'X-Catalyst-query' => $uri->query);
43 $c->forward('TestApp::View::Dump::Request');
46 sub uri_with_object : Local {
47 my ( $self, $c ) = @_;
49 my $uri = $c->req->uri_with( { a => $c->req->base } );
50 my %query = $uri->query_form;
52 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
54 $c->forward('TestApp::View::Dump::Request');
57 sub uri_with_utf8 : Local {
58 my ( $self, $c ) = @_;
60 # change the current uri
61 my $uri = $c->req->uri_with( { unicode => "\x{2620}" } );
63 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
65 $c->forward('TestApp::View::Dump::Request');
68 sub uri_with_undef : Local {
69 my ( $self, $c ) = @_;
72 local $SIG{__WARN__} = sub { $warnings++ };
74 # change the current uri
75 my $uri = $c->req->uri_with( { foo => undef } );
77 $c->res->header( 'X-Catalyst-warnings' => $warnings );
79 $c->forward('TestApp::View::Dump::Request');
82 sub uri_with_undef_only : Local {
83 my ( $self, $c ) = @_;
85 my $uri = $c->req->uri_with( { a => undef } );
87 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
88 $c->forward('TestApp::View::Dump::Request');
91 sub uri_with_undef_ignore : Local {
92 my ( $self, $c ) = @_;
94 my $uri = $c->req->uri_with( { a => 1, b => undef } );
96 my %query = $uri->query_form;
97 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
98 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
99 $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );
100 $c->res->header( 'X-Catalyst-Param-c' => $query{ c } );
101 $c->forward('TestApp::View::Dump::Request');