10 use HTTP::Request::Common;
15 # perl < 5.8.9 won't set a %SIG entry to undef, it sets it to ''
16 %orig_sig = map { defined $_ ? $_ : '' } %orig_sig
20 use Catalyst::Test 'TestCGIBin';
22 # this should be ignored
23 $ENV{MOD_PERL} = "mod_perl/2.0";
25 is_deeply \%SIG, \%orig_sig, '%SIG is preserved on compile';
27 my $response = request POST '/my-bin/path/test.pl', [
32 is($response->content, 'foo:bar bar:baz', 'POST to Perl CGI File');
34 $response = request '/my-bin/path/test.pl?foo=bar&bar=baz';
36 is($response->content, 'foo:bar bar:baz',
37 'Perl CGI File invoked with query params');
39 $response = request POST '/my-bin/exit.pl', [
43 is($response->content, 'hello world', 'POST to Perl CGI with exit()');
45 $response = request POST '/my-bin/exit.pl', [
50 is($response->code, 500, 'POST to Perl CGI with nonzero exit()');
52 $response = request '/my-bin/ignored.cgi';
54 is($response->code, 500, "file not matching 'cgi_file_pattern' is ignored");
56 $response = request POST '/cgihandler/mtfnpy', [
61 is($response->content, 'foo:bar bar:baz',
62 'POST to Perl CGI File through a forward via cgi_action');
64 $response = request '/my-bin/path/testdata.pl';
65 like($response->content, qr/^testing\r?\n\z/,
66 'scripts with __DATA__ sections work');
68 $response = request '/my-bin/pathinfo.pl/path/info';
69 is($response->content, '/path/info',
72 ok request '/my-bin/sigs.pl';
74 is_deeply \%SIG, \%orig_sig, '%SIG is preserved';
77 skip "Can't run shell scripts on non-*nix", 1
78 if $^O eq 'MSWin32' || $^O eq 'VMS';
80 # for some reason the +x is not preserved in the dist
81 system "chmod +x $Bin/lib/TestCGIBin/root/cgi-bin/test.sh";
82 system "chmod +x $Bin/lib/TestCGIBin/root/cgi-bin/exit_nonzero.sh";
84 is(get('/my-bin/test.sh'), "Hello!\n", 'Non-Perl CGI File');
86 $response = request GET '/my-bin/exit_nonzero.sh';
87 is $response->code, 500, 'Non-Perl CGI with non-zero exit dies';
90 { $response = get('/my-bin/time.pl');
92 my $response_2 = get('/my-bin/time.pl');
93 isnt( $response, $response_2, 'cgis are getting invoked each time' );