drain backend socket/pipe bufs upon FDEVENT_HUP
[lighttpd.git] / tests / core-keepalive.t
blobb4f51f901e998c6768dc6ea338bfb41053944c0b
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 IO::Socket;
11 use Test::More tests => 7;
12 use LightyTest;
14 my $tf = LightyTest->new();
15 my $t;
17 ok($tf->start_proc == 0, "Starting lighttpd") or die();
19 $t->{REQUEST} = ( <<EOF
20 GET /12345.txt HTTP/1.0
21 Connection: keep-alive
22 Host: 123.example.org
24 GET /12345.txt HTTP/1.0
25 Host: 123.example.org
26 Connection: close
27 EOF
29 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
31 ok($tf->handle_http($t) == 0, 'Explicit HTTP/1.0 Keep-Alive');
33 undef $t->{RESPONSE};
35 $t->{REQUEST} = ( <<EOF
36 GET /12345.txt HTTP/1.0
37 Connection: keep-alive
38 Host: 123.example.org
40 GET /12345.txt HTTP/1.0
41 Host: 123.example.org
42 Connection: close
43 EOF
45 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
47 ok($tf->handle_http($t) == 0, 'Explicit HTTP/1.0 Keep-Alive');
49 undef $t->{RESPONSE};
51 $t->{REQUEST} = ( <<EOF
52 GET /12345.txt HTTP/1.0
53 Connection: keep-alive
54 Host: 123.example.org
56 GET /12345.txt HTTP/1.0
57 Host: 123.example.org
58 EOF
60 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
61 ok($tf->handle_http($t) == 0, 'Implicit HTTP/1.0 Keep-Alive');
64 $t->{REQUEST} = ( <<EOF
65 GET /12345.txt HTTP/1.1
66 Connection: keep-alive
67 Host: 123.example.org
69 GET /12345.txt HTTP/1.1
70 Host: 123.example.org
71 Connection: close
72 EOF
74 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
75 ok($tf->handle_http($t) == 0, 'Explicit HTTP/1.1 Keep-Alive');
77 $t->{REQUEST} = ( <<EOF
78 GET /12345.txt HTTP/1.1
79 Host: 123.example.org
81 GET /12345.txt HTTP/1.1
82 Host: 123.example.org
83 Connection: close
84 EOF
87 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
89 ok($tf->handle_http($t) == 0, 'Implicit HTTP/1.1 Keep-Alive');
91 ok($tf->stop_proc == 0, "Stopping lighttpd");