318c89048a66a653c89ba5e3c3737e2a588a294f
[catagits/Catalyst-Controller-WrapCGI.git] / t / lib / TestApp / Controller / Root.pm
1 package TestApp::Controller::Root;
2
3 use parent 'Catalyst::Controller::WrapCGI';
4 use CGI ();
5
6 __PACKAGE__->config->{namespace} = '';
7
8 my $cgi = sub {
9     my $cgi = CGI->new;
10     print $cgi->header;
11     print 'foo:',$cgi->param('foo'),' bar:',$cgi->param('bar');
12     if (my $fh = $cgi->param('baz')) {
13       local $/;
14       print ' baz:',<$fh>;
15     }
16     if (my $fh = $cgi->param('quux')) {
17       local $/;
18       print ' quux:',<$fh>;
19     }
20     die $cgi->cgi_error if $cgi->cgi_error;
21 };
22
23 sub handle_cgi : Path('/cgi-bin/test.cgi') {
24     my ($self, $c) = @_;
25     $self->cgi_to_response($c, $cgi);
26 }
27
28 sub test_path_info : Path('/cgi-bin/test_pathinfo.cgi') {
29     my ($self, $c) = @_;
30
31     $self->cgi_to_response($c, sub {
32         my $cgi = CGI->new;
33         print $cgi->header;
34         print $ENV{PATH_INFO}
35     });
36 }
37
38 sub test_filepath_info : Path('/cgi-bin/test_filepathinfo.cgi') {
39     my ($self, $c) = @_;
40
41     $self->cgi_to_response($c, sub {
42         my $cgi = CGI->new;
43         print $cgi->header;
44         print $ENV{FILEPATH_INFO}
45     });
46 }
47
48 sub test_script_name : Path('/cgi-bin/test_scriptname.cgi') {
49     my ($self, $c) = @_;
50
51     $self->cgi_to_response($c, sub {
52         my $cgi = CGI->new;
53         print $cgi->header;
54         print $ENV{SCRIPT_NAME}
55     });
56 }
57
58 1;