1 package TestApp::Controller::Root;
4 use base 'Catalyst::Controller';
7 __PACKAGE__->config->{namespace} = '';
9 sub chain_root_index : Chained('/') PathPart('') Args(0) { }
11 sub zero : Path('0') {
12 my ( $self, $c ) = @_;
13 $c->res->header( 'X-Test-Class' => ref($self) );
14 $c->response->content_type('text/plain; charset=utf-8');
15 $c->forward('TestApp::View::Dump::Request');
18 sub zerobody : Local {
23 sub emptybody : Local {
29 my ( $self, $c ) = @_;
30 $c->res->body('root index');
33 sub global_action : Private {
34 my ( $self, $c ) = @_;
35 $c->forward('TestApp::View::Dump::Request');
38 sub class_forward_test_method :Private {
39 my ( $self, $c ) = @_;
40 $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 );
43 sub loop_test : Local {
44 my ( $self, $c ) = @_;
47 $c->forward( 'class_forward_test_method' );
51 sub recursion_test : Local {
52 my ( $self, $c ) = @_;
53 no warnings 'recursion';
54 $c->forward( 'recursion_test' );
57 sub base_href_test : Local {
58 my ( $self, $c ) = @_;
60 my $body = <<"EndOfBody";
63 <base href="http://www.example.com/">
70 $c->response->body($body);
73 sub body_semipredicate : Local {
75 $c->res->body; # Old code tests length($c->res->body), which causes the value to be built (undef), which causes the predicate
76 $c->res->status( $c->res->has_body ? 500 : 200 ); # to return the wrong thing, resulting in a 500.
77 $c->res->body('Body');
81 sub test_redirect :Global {
83 # Don't set content_type
85 $c->res->redirect('/go_here');
88 sub test_redirect_uri_for :Global {
90 # Don't set content_type
92 $c->res->redirect($c->uri_for('/go_here'));
95 sub test_redirect_with_contenttype :Global {
97 # set content_type but don't set body
98 $c->res->content_type('image/jpeg');
99 $c->res->redirect('/go_here');
102 sub test_redirect_with_content :Global {
104 $c->res->content_type('text/plain');
105 $c->res->body('Please kind sir, I beg you to go to /go_here.');
106 $c->res->redirect('/go_here');