- next is 1.4.56
[lighttpd.git] / tests / core-request.t
blob1418fb25928a9fe1e64a82f8b771b8f3c208ae2a
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 => 12;
12 use LightyTest;
14 my $tf = LightyTest->new();
15 my $t;
17 ok($tf->start_proc == 0, "Starting lighttpd") or die();
20 $t->{REQUEST} = ( <<EOF
21 GET / HTTP/1.0
22 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
28 OPTIONS * HTTP/1.0
29 EOF
31 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
32 ok($tf->handle_http($t) == 0, 'OPTIONS');
34 $t->{REQUEST} = ( <<EOF
35 OPTIONS / HTTP/1.1
36 Host: www.example.org
37 Connection: close
38 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
48 EOF
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
55 EOF
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
62 Host: 123.example.org
63 Content-Length: 2147483648
64 EOF
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
73 EOF
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
80 EOF
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
86 GET /a HTTP/1.0
87 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
93 GET /Foo.txt HTTP/1.0
94 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");