Annotation of embedaddon/lighttpd/tests/core-response.t, revision 1.1
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;
! 11: use Test::More tests => 12;
! 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');
! 88:
! 89: ## simple-vhost
! 90:
! 91: $t->{REQUEST} = ( <<EOF
! 92: GET /12345.txt HTTP/1.0
! 93: Host: no-simple.example.org
! 94: EOF
! 95: );
! 96: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => '6' } ];
! 97: ok($tf->handle_http($t) == 0, 'disabling simple-vhost via conditionals');
! 98:
! 99: $t->{REQUEST} = ( <<EOF
! 100: GET /12345.txt HTTP/1.0
! 101: Host: simple.example.org
! 102: EOF
! 103: );
! 104: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
! 105: ok($tf->handle_http($t) == 0, 'simple-vhost via conditionals');
! 106:
! 107: ok($tf->stop_proc == 0, "Stopping lighttpd");
! 108:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>