[core] use con->dst_addr_buf instead of ip recalc
[lighttpd.git] / tests / mod-scgi.t
blob12c11a80b54f30f24397d657426374ebcd54bd6f
1 #!/usr/bin/env perl
2 BEGIN {
3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s,/[^/]+$,/,;
6 unshift @INC, $srcdir;
9 use strict;
10 use Test::More tests => 10;
11 use LightyTest;
13 my $tf = LightyTest->new();
14 my $t;
16 SKIP: {
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
23 Host: www.example.org
24 EOF
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
31 Host: www.example.org
32 EOF
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
39 Host: www.example.org
40 EOF
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
47 Host: www.example.org
48 EOF
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
56 EOF
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
64 EOF
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
72 Host: www.example.org
73 EOF
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
85 Host: www.example.org
86 EOF
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");