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
$tf->{CONFIGFILE} = 'lighttpd.conf';
19
ok($tf->start_proc == 0, "Starting lighttpd") or die();
21
## check if If-Modified-Since, If-None-Match works
23
$t->{REQUEST} = ( <<EOF
25
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT
28
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
29
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since');
31
$t->{REQUEST} = ( <<EOF
33
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
36
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Last-Modified' => ''} ];
37
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since, comment');
41
$t->{REQUEST} = ( <<EOF
43
If-Modified-Since: $now
46
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
47
ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since');
49
$t->{REQUEST} = ( <<EOF
51
If-Modified-Since: $now; foo
54
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
55
ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since, comment');
57
$t->{REQUEST} = ( <<EOF
62
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+ETag' => ''} ];
63
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match');
65
my $etag = $t->{etag};
67
$t->{REQUEST} = ( <<EOF
72
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
73
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match');
75
$t->{REQUEST} = ( <<EOF
78
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
81
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
82
ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + old Last-Modified');
84
$t->{REQUEST} = ( <<EOF
87
If-Modified-Since: $now; foo
90
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
91
ok($tf->handle_http($t) == 0, 'Conditional GET - ETag, Last-Modified + comment');
93
$t->{REQUEST} = ( <<EOF
96
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
99
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
100
ok($tf->handle_http($t) == 0, 'Conditional GET - old ETAG + old Last-Modified');
102
$t->{REQUEST} = ( <<EOF
105
If-Modified-Since: $now foo
108
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 412 } ];
109
ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + Last-Modified + overlong timestamp');
111
ok($tf->stop_proc == 0, "Stopping lighttpd");