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
=> 12;
14 my $tf = LightyTest
->new();
17 ok
($tf->start_proc == 0, "Starting lighttpd") or die();
20 $t->{REQUEST
} = ( <<EOF
24 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
25 ok
($tf->handle_http($t) == 0, 'Valid HTTP/1.0 Request') or die();
27 $t->{REQUEST
} = ( <<EOF
31 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
32 ok
($tf->handle_http($t) == 0, 'OPTIONS');
34 $t->{REQUEST
} = ( <<EOF
40 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
41 ok
($tf->handle_http($t) == 0, 'OPTIONS');
44 ## Low-Level Request-Header Parsing - URI
46 $t->{REQUEST
} = ( <<EOF
47 GET /index%2ehtml HTTP/1.0
50 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
51 ok
($tf->handle_http($t) == 0, 'URL-encoding');
53 $t->{REQUEST
} = ( <<EOF
54 GET /index.html%00 HTTP/1.0
57 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
58 ok
($tf->handle_http($t) == 0, 'URL-encoding, %00');
60 $t->{REQUEST
} = ( <<EOF
61 POST /12345.txt HTTP/1.0
63 Content-Length: 2147483648
66 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 413 } ];
67 ok
($tf->handle_http($t) == 0, 'Content-Length > max-request-size');
70 print "\nContent-Type\n";
71 $t->{REQUEST
} = ( <<EOF
72 GET /image.jpg HTTP/1.0
75 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } ];
76 ok
($tf->handle_http($t) == 0, 'Content-Type - image/jpeg');
78 $t->{REQUEST
} = ( <<EOF
79 GET /image.JPG HTTP/1.0
82 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } ];
83 ok
($tf->handle_http($t) == 0, 'Content-Type - image/jpeg (upper case)');
85 $t->{REQUEST
} = ( <<EOF
89 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'application/octet-stream' } ];
90 ok
($tf->handle_http($t) == 0, 'Content-Type - unknown');
92 $t->{REQUEST
} = ( <<EOF
96 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
97 ok
($tf->handle_http($t) == 0, 'uppercase filenames');
100 ok
($tf->stop_proc == 0, "Stopping lighttpd");