3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s
,/[^/]+$,/,;
10 use Test
::More tests
=> 10;
13 my $tf = LightyTest
->new();
17 skip
"no scgi-responder found", 10 unless -x
$tf->{BASEDIR
}."/tests/scgi-responder" || -x
$tf->{BASEDIR
}."/tests/scgi-responder.exe";
19 $tf->{CONFIGFILE
} = 'scgi-responder.conf';
20 ok
($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die();
21 $t->{REQUEST
} = ( <<EOF
22 GET /index.scgi?lf HTTP/1.0
26 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
27 ok
($tf->handle_http($t) == 0, 'line-ending \n\n');
29 $t->{REQUEST
} = ( <<EOF
30 GET /index.scgi?crlf HTTP/1.0
34 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
35 ok
($tf->handle_http($t) == 0, 'line-ending \r\n\r\n');
37 $t->{REQUEST
} = ( <<EOF
38 GET /index.scgi?slow-lf HTTP/1.0
42 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
43 ok
($tf->handle_http($t) == 0, 'line-ending \n + \n');
45 $t->{REQUEST
} = ( <<EOF
46 GET /index.scgi?slow-crlf HTTP/1.0
50 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
51 ok
($tf->handle_http($t) == 0, 'line-ending \r\n + \r\n');
53 $t->{REQUEST
} = ( <<EOF
54 GET /abc/def/ghi?path_info HTTP/1.0
55 Host: wsgi.example.org
58 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/abc/def/ghi' } ];
59 ok
($tf->handle_http($t) == 0, 'PATH_INFO (wsgi)');
61 $t->{REQUEST
} = ( <<EOF
62 GET /abc/def/ghi?script_name HTTP/1.0
63 Host: wsgi.example.org
66 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ];
67 ok
($tf->handle_http($t) == 0, 'SCRIPT_NAME (wsgi)');
70 $t->{REQUEST
} = ( <<EOF
71 GET /index.scgi?die-at-end HTTP/1.0
75 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
76 ok
($tf->handle_http($t) == 0, 'killing scgi and wait for restart');
78 # (might take lighttpd 1 sec to detect backend exit)
79 select(undef, undef, undef, .5);
80 for (my $c = 2*20; $c && 0 == $tf->listening_on(10000); --$c) {
81 select(undef, undef, undef, 0.05);
83 $t->{REQUEST
} = ( <<EOF
84 GET /index.scgi?crlf HTTP/1.0
88 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
89 ok
($tf->handle_http($t) == 0, 'regular response of after restart');
92 ok
($tf->stop_proc == 0, "Stopping lighttpd");