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 } );
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 } );
41 $c->forward('TestApp::View::Dump::Request');
44 sub uri_with_object : Local {
45 my ( $self, $c ) = @_;
47 my $uri = $c->req->uri_with( { a => $c->req->base } );
48 my %query = $uri->query_form;
50 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
52 $c->forward('TestApp::View::Dump::Request');
55 sub uri_with_utf8 : Local {
56 my ( $self, $c ) = @_;
58 # change the current uri
59 my $uri = $c->req->uri_with( { unicode => "\x{2620}" } );
61 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
63 $c->forward('TestApp::View::Dump::Request');
66 sub uri_with_undef : Local {
67 my ( $self, $c ) = @_;
70 local $SIG{__WARN__} = sub { $warnings++ };
72 # change the current uri
73 my $uri = $c->req->uri_with( { foo => undef } );
75 $c->res->header( 'X-Catalyst-warnings' => $warnings );
77 $c->forward('TestApp::View::Dump::Request');
80 sub uri_with_undef_only : Local {
81 my ( $self, $c ) = @_;
83 my $uri = $c->req->uri_with( { a => undef } );
85 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
86 $c->forward('TestApp::View::Dump::Request');
89 sub uri_with_undef_ignore : Local {
90 my ( $self, $c ) = @_;
92 my $uri = $c->req->uri_with( { a => 1, b => undef } );
94 my %query = $uri->query_form;
95 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
96 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
97 $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );
98 $c->res->header( 'X-Catalyst-Param-c' => $query{ c } );
99 $c->forward('TestApp::View::Dump::Request');