3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s
,/[^/]+$,/,;
11 use Test
::More tests
=> 18;
14 my $tf = LightyTest
->new();
17 ok
($tf->start_proc == 0, "Starting lighttpd") or die();
21 $t->{REQUEST
} = ( <<EOF
25 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
26 ok
($tf->handle_http($t) == 0, 'perl via cgi');
28 $t->{REQUEST
} = ( <<EOF
29 GET /cgi.pl/foo HTTP/1.0
32 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/cgi.pl' } ];
33 ok
($tf->handle_http($t) == 0, 'perl via cgi + pathinfo');
35 $t->{REQUEST
} = ( <<EOF
36 GET /cgi-pathinfo.pl/foo HTTP/1.0
39 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo' } ];
40 ok
($tf->handle_http($t) == 0, 'perl via cgi + pathinfo');
42 $t->{REQUEST
} = ( <<EOF
43 GET /nph-status.pl?30 HTTP/1.0
46 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
47 ok
($tf->handle_http($t) == 0, 'NPH + perl, invalid status-code (#14)');
49 $t->{REQUEST
} = ( <<EOF
50 GET /nph-status.pl?304 HTTP/1.0
53 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
54 ok
($tf->handle_http($t) == 0, 'NPH + perl, setting status-code (#1125)');
56 $t->{REQUEST
} = ( <<EOF
57 GET /nph-status.pl?200 HTTP/1.0
60 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
61 ok
($tf->handle_http($t) == 0, 'NPH + perl, setting status-code');
63 $t->{REQUEST
} = ( <<EOF
64 GET /get-header.pl?GATEWAY_INTERFACE HTTP/1.0
67 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'CGI/1.1' } ];
68 ok
($tf->handle_http($t) == 0, 'cgi-env: GATEWAY_INTERFACE');
70 $t->{REQUEST
} = ( <<EOF
71 GET /get-header.pl?QUERY_STRING HTTP/1.0
74 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'QUERY_STRING' } ];
75 ok
($tf->handle_http($t) == 0, 'cgi-env: QUERY_STRING');
77 $t->{REQUEST
} = ( <<EOF
78 GET /get-header.pl?GATEWAY_INTERFACE HTTP/1.0
81 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'CGI/1.1' } ];
82 ok
($tf->handle_http($t) == 0, 'cgi-env: GATEWAY_INTERFACE');
84 $t->{REQUEST
} = ( <<EOF
85 GET /get-header.pl?HTTP_HOST HTTP/1.0
89 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org' } ];
90 ok
($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
92 $t->{REQUEST
} = ( <<EOF
93 GET /get-header.pl?HTTP_XX_YY123 HTTP/1.0
97 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'foo' } ];
98 ok
($tf->handle_http($t) == 0, 'cgi-env: quoting headers with numbers');
100 $t->{REQUEST
} = ( <<EOF
101 GET /get-header.pl?HTTP_HOST HTTP/1.0
102 Host: www.example.org
105 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org' } ];
106 ok
($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
108 $t->{REQUEST
} = ( <<EOF
109 GET /get-header.pl?HTTP_HOST HTTP/1.0
110 Host: www.example.org
113 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org' } ];
114 ok
($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
116 $t->{REQUEST
} = ( <<EOF
117 GET /get-header.pl?HTTP_HOST HTTP/1.0
118 Host: www.example.org
121 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'text/plain' } ];
122 ok
($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
124 $t->{REQUEST
} = ( <<EOF
125 GET /get-header.pl?HTTP_HOST HTTP/1.1
126 Host: www.example.org
130 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, '+Content-Length' => '' } ];
131 ok
($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
133 # broken header crash
134 $t->{REQUEST
} = ( <<EOF
135 GET /crlfcrash.pl HTTP/1.0
138 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org/' } ];
139 ok
($tf->handle_http($t) == 0, 'broken header via perl cgi');
141 ok
($tf->stop_proc == 0, "Stopping lighttpd");