1#!/usr/bin/env perl 2BEGIN { 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; 7} 8 9use strict; 10use IO::Socket; 11use Test::More tests => 7; 12use LightyTest; 13 14my $tf = LightyTest->new(); 15my $t; 16 17ok($tf->start_proc == 0, "Starting lighttpd") or die(); 18 19$t->{REQUEST} = ( <<EOF 20GET /12345.txt HTTP/1.0 21Connection: keep-alive 22Host: 123.example.org 23 24GET /12345.txt HTTP/1.0 25Host: 123.example.org 26Connection: close 27EOF 28 ); 29$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 30 31ok($tf->handle_http($t) == 0, 'Explicit HTTP/1.0 Keep-Alive'); 32 33undef $t->{RESPONSE}; 34 35$t->{REQUEST} = ( <<EOF 36GET /12345.txt HTTP/1.0 37Connection: keep-alive 38Host: 123.example.org 39 40GET /12345.txt HTTP/1.0 41Host: 123.example.org 42Connection: close 43EOF 44 ); 45$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 46 47ok($tf->handle_http($t) == 0, 'Explicit HTTP/1.0 Keep-Alive'); 48 49undef $t->{RESPONSE}; 50 51$t->{REQUEST} = ( <<EOF 52GET /12345.txt HTTP/1.0 53Connection: keep-alive 54Host: 123.example.org 55 56GET /12345.txt HTTP/1.0 57Host: 123.example.org 58EOF 59 ); 60$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 61ok($tf->handle_http($t) == 0, 'Implicit HTTP/1.0 Keep-Alive'); 62 63 64$t->{REQUEST} = ( <<EOF 65GET /12345.txt HTTP/1.1 66Connection: keep-alive 67Host: 123.example.org 68 69GET /12345.txt HTTP/1.1 70Host: 123.example.org 71Connection: close 72EOF 73 ); 74$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ]; 75ok($tf->handle_http($t) == 0, 'Explicit HTTP/1.1 Keep-Alive'); 76 77$t->{REQUEST} = ( <<EOF 78GET /12345.txt HTTP/1.1 79Host: 123.example.org 80 81GET /12345.txt HTTP/1.1 82Host: 123.example.org 83Connection: close 84EOF 85 ); 86 87$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } , { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ]; 88 89ok($tf->handle_http($t) == 0, 'Implicit HTTP/1.1 Keep-Alive'); 90 91ok($tf->stop_proc == 0, "Stopping lighttpd"); 92