Merge branch 'master' into psgi
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Root.pm
1 package TestApp::Controller::Root;
2 use strict;
3 use warnings;
4 use base 'Catalyst::Controller';
5
6 __PACKAGE__->config->{namespace} = '';
7
8 sub chain_root_index : Chained('/') PathPart('') Args(0) { }
9
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
17 sub localregex : LocalRegex('^localregex$') {
18     my ( $self, $c ) = @_;
19     $c->res->header( 'X-Test-Class' => ref($self) );
20     $c->response->content_type('text/plain; charset=utf-8');
21     $c->forward('TestApp::View::Dump::Request');
22 }
23
24 sub index : Private {
25     my ( $self, $c ) = @_;
26     $c->res->body('root index');
27 }
28
29 sub global_action : Private {
30     my ( $self, $c ) = @_;
31     $c->forward('TestApp::View::Dump::Request');
32 }
33
34 sub class_forward_test_method :Private {
35     my ( $self, $c ) = @_;
36     $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 );
37 }
38
39 sub loop_test : Local {
40     my ( $self, $c ) = @_;
41
42     for( 1..1001 ) {
43         $c->forward( 'class_forward_test_method' );
44     }
45 }
46
47 sub recursion_test : Local {
48     my ( $self, $c ) = @_;
49     $c->forward( 'recursion_test' );
50 }
51
52 sub base_href_test : Local {
53     my ( $self, $c ) = @_;
54
55     my $body = <<"EndOfBody";
56 <html>
57   <head>
58     <base href="http://www.example.com/">
59   </head>
60   <body>
61   </body>
62 </html>
63 EndOfBody
64
65     $c->response->body($body);
66 }
67
68 sub end : Private {
69     my ($self,$c) = @_;
70 }
71
72 1;