Annotation of embedaddon/lighttpd/tests/core-response.t, revision 1.1.1.2
1.1 misho 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;
7: }
8:
9: use strict;
10: use IO::Socket;
1.1.1.2 ! misho 11: use Test::More tests => 14;
1.1 misho 12: use LightyTest;
13:
14: my $tf = LightyTest->new();
15: my $t;
16:
17: ok($tf->start_proc == 0, "Starting lighttpd") or die();
18:
19: ## Low-Level Response-Header Parsing - HTTP/1.1
20:
21: $t->{REQUEST} = ( <<EOF
22: GET / HTTP/1.1
23: Host: www.example.org
24: Connection: close
25: EOF
26: );
27: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, '+Date' => '' } ];
28: ok($tf->handle_http($t) == 0, 'Date header');
29:
30: $t->{REQUEST} = ( <<EOF
31: GET / HTTP/1.1
32: EOF
33: );
34: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400, 'Connection' => 'close' } ];
35: ok($tf->handle_http($t) == 0, 'Host missing');
36:
37: $t->{REQUEST} = ( <<EOF
38: GET / HTTP/1.0
39: EOF
40: );
41: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+ETag' => '' } ];
42: ok($tf->handle_http($t) == 0, 'ETag is set');
43:
44: $t->{REQUEST} = ( <<EOF
45: GET / HTTP/1.0
46: EOF
47: );
48: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'ETag' => '/^".+"$/' } ];
49: ok($tf->handle_http($t) == 0, 'ETag has quotes');
50:
51:
52:
53: ## Low-Level Response-Header Parsing - Content-Length
54:
55:
56: $t->{REQUEST} = ( <<EOF
57: GET /12345.html HTTP/1.0
58: Host: 123.example.org
59: EOF
60: );
61: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => '6' } ];
62: ok($tf->handle_http($t) == 0, 'Content-Length for text/html');
63:
64: $t->{REQUEST} = ( <<EOF
65: GET /12345.txt HTTP/1.0
66: Host: 123.example.org
67: EOF
68: );
69: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => '6' } ];
70: ok($tf->handle_http($t) == 0, 'Content-Length for text/plain');
71:
72:
73: ## Low-Level Response-Header Parsing - Location
74:
75: $t->{REQUEST} = ( <<EOF
76: GET /dummydir HTTP/1.0
77: EOF
78: );
79: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/dummydir/' } ];
80: ok($tf->handle_http($t) == 0, 'internal redirect in directory');
81:
82: $t->{REQUEST} = ( <<EOF
83: GET /dummydir?foo HTTP/1.0
84: EOF
85: );
86: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/dummydir/?foo' } ];
87: ok($tf->handle_http($t) == 0, 'internal redirect in directory + querystring');
1.1.1.2 ! misho 88:
! 89: $t->{REQUEST} = ( <<EOF
! 90: GET /~test%20ä_ HTTP/1.0
! 91: EOF
! 92: );
! 93: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/~test%20%c3%a4_/' } ];
! 94: ok($tf->handle_http($t) == 0, 'internal redirect in directory with special characters');
! 95:
! 96: $t->{REQUEST} = ( <<EOF
! 97: GET /~test%20ä_?foo HTTP/1.0
! 98: EOF
! 99: );
! 100: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/~test%20%c3%a4_/?foo' } ];
! 101: ok($tf->handle_http($t) == 0, 'internal redirect in directory with special characters + querystring');
1.1 misho 102:
103: ## simple-vhost
104:
105: $t->{REQUEST} = ( <<EOF
106: GET /12345.txt HTTP/1.0
107: Host: no-simple.example.org
108: EOF
109: );
110: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => '6' } ];
111: ok($tf->handle_http($t) == 0, 'disabling simple-vhost via conditionals');
112:
113: $t->{REQUEST} = ( <<EOF
114: GET /12345.txt HTTP/1.0
115: Host: simple.example.org
116: EOF
117: );
118: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
119: ok($tf->handle_http($t) == 0, 'simple-vhost via conditionals');
120:
121: ok($tf->stop_proc == 0, "Stopping lighttpd");
122:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>