Commit | Line | Data |
32d5a0c5 |
1 | package TestApp::Controller::Root; |
5ab21903 |
2 | use strict; |
3 | use warnings; |
32d5a0c5 |
4 | use base 'Catalyst::Controller'; |
5 | |
6 | __PACKAGE__->config->{namespace} = ''; |
7 | |
81e75875 |
8 | sub chain_root_index : Chained('/') PathPart('') Args(0) { } |
9 | |
53119b78 |
10 | sub zero : Path('0') { |
11 | my ( $self, $c ) = @_; |
12 | $c->res->header( 'X-Test-Class' => ref($self) ); |
13 | $c->response->content_type('text/plain; charset=utf-8'); |
14 | $c->forward('TestApp::View::Dump::Request'); |
15 | } |
16 | |
bcc7361a |
17 | sub zerobody : Local { |
18 | my ($self, $c) = @_; |
19 | $c->res->body('0'); |
20 | } |
21 | |
22 | sub emptybody : Local { |
23 | my ($self, $c) = @_; |
24 | $c->res->body(''); |
25 | } |
26 | |
a202886b |
27 | sub index : Private { |
28 | my ( $self, $c ) = @_; |
29 | $c->res->body('root index'); |
30 | } |
31 | |
32 | sub global_action : Private { |
33 | my ( $self, $c ) = @_; |
34 | $c->forward('TestApp::View::Dump::Request'); |
35 | } |
36 | |
37 | sub class_forward_test_method :Private { |
38 | my ( $self, $c ) = @_; |
39 | $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 ); |
40 | } |
41 | |
42 | sub loop_test : Local { |
43 | my ( $self, $c ) = @_; |
44 | |
45 | for( 1..1001 ) { |
46 | $c->forward( 'class_forward_test_method' ); |
47 | } |
48 | } |
49 | |
50 | sub recursion_test : Local { |
51 | my ( $self, $c ) = @_; |
421ae538 |
52 | no warnings 'recursion'; |
a202886b |
53 | $c->forward( 'recursion_test' ); |
54 | } |
55 | |
f23f1634 |
56 | sub base_href_test : Local { |
57 | my ( $self, $c ) = @_; |
58 | |
59 | my $body = <<"EndOfBody"; |
60 | <html> |
61 | <head> |
62 | <base href="http://www.example.com/"> |
63 | </head> |
64 | <body> |
65 | </body> |
66 | </html> |
67 | EndOfBody |
68 | |
69 | $c->response->body($body); |
70 | } |
71 | |
ffb43803 |
72 | sub body_semipredicate : Local { |
73 | my ($self, $c) = @_; |
74 | $c->res->body; # Old code tests length($c->res->body), which causes the value to be built (undef), which causes the predicate |
75 | $c->res->status( $c->res->has_body ? 500 : 200 ); # to return the wrong thing, resulting in a 500. |
76 | $c->res->body('Body'); |
77 | } |
78 | |
d67d5f87 |
79 | |
80 | sub test_redirect :Global { |
81 | my ($self, $c) = @_; |
82 | # Don't set content_type |
83 | # Don't set body |
84 | $c->res->redirect('/go_here'); |
85 | } |
86 | |
7af54927 |
87 | sub test_redirect_uri_for :Global { |
88 | my ($self, $c) = @_; |
89 | # Don't set content_type |
90 | # Don't set body |
91 | $c->res->redirect($c->uri_for('/go_here')); |
92 | } |
93 | |
d67d5f87 |
94 | sub test_redirect_with_contenttype :Global { |
95 | my ($self, $c) = @_; |
96 | # set content_type but don't set body |
97 | $c->res->content_type('image/jpeg'); |
98 | $c->res->redirect('/go_here'); |
99 | } |
100 | |
101 | sub test_redirect_with_content :Global { |
102 | my ($self, $c) = @_; |
103 | $c->res->content_type('text/plain'); |
104 | $c->res->body('Please kind sir, I beg you to go to /go_here.'); |
105 | $c->res->redirect('/go_here'); |
106 | } |
107 | |
a0a66cb8 |
108 | sub end : Private { |
109 | my ($self,$c) = @_; |
110 | } |
111 | |
32d5a0c5 |
112 | 1; |