diff options
author | Jan Kneschke <jan@kneschke.de> | 2006-09-07 12:28:48 +0000 |
---|---|---|
committer | Jan Kneschke <jan@kneschke.de> | 2006-09-07 12:28:48 +0000 |
commit | 7d4d819599ae80dea19d8bf6396a3e1fa5cdee0f (patch) | |
tree | 26b177b8e58ba0c204c60e4137dfbfaeb3663274 /tests | |
parent | 08994e478aee895458931590c0236e5696640972 (diff) | |
download | lighttpd-git-7d4d819599ae80dea19d8bf6396a3e1fa5cdee0f.tar.gz |
merged [1055], [1056], [1068], [1172], [1176]
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.11-ssl-fixes@1286 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/LightyTest.pm | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 5 | ||||
-rwxr-xr-x | tests/cachable.t | 112 |
3 files changed, 119 insertions, 1 deletions
diff --git a/tests/LightyTest.pm b/tests/LightyTest.pm index 81f92922..49d2175b 100755 --- a/tests/LightyTest.pm +++ b/tests/LightyTest.pm @@ -195,6 +195,9 @@ sub handle_http { } } + $t->{etag} = $resp_hdr{'etag'}; + $t->{date} = $resp_hdr{'date'}; + # check length if (defined $resp_hdr{"content-length"}) { $resp_body = substr($lines, 0, $resp_hdr{"content-length"}); diff --git a/tests/Makefile.am b/tests/Makefile.am index d4a9b109..584d9c98 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,7 +42,10 @@ CONFS=fastcgi-10.conf \ request.t \ mod-ssi.t \ LightyTest.pm \ - mod-setenv.t + mod-setenv.t \ + lowercase.t \ + lowercase.conf \ + cachable.t TESTS_ENVIRONMENT=$(srcdir)/wrapper.sh $(srcdir) $(top_builddir) diff --git a/tests/cachable.t b/tests/cachable.t new file mode 100755 index 00000000..74d9a4b1 --- /dev/null +++ b/tests/cachable.t @@ -0,0 +1,112 @@ +#!/usr/bin/env perl +BEGIN { + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s#/[^/]+$#/#; + unshift @INC, $srcdir; +} + +use strict; +use IO::Socket; +use Test::More tests => 12; +use LightyTest; + +my $tf = LightyTest->new(); +my $t; + +$tf->{CONFIGFILE} = 'lighttpd.conf'; + +ok($tf->start_proc == 0, "Starting lighttpd") or die(); + +## check if If-Modified-Since, If-None-Match works + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since'); + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Last-Modified' => ''} ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since, comment'); + +my $now = $t->{date}; + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-Modified-Since: $now +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since'); + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-Modified-Since: $now; foo +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since, comment'); + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-None-Match: foo +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+ETag' => ''} ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match'); + +my $etag = $t->{etag}; + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-None-Match: $etag +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match'); + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-None-Match: $etag +If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + old Last-Modified'); + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-None-Match: $etag +If-Modified-Since: $now; foo +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - ETag, Last-Modified + comment'); + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-None-Match: Foo +If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - old ETAG + old Last-Modified'); + +$t->{REQUEST} = ( <<EOF +GET / HTTP/1.0 +If-None-Match: $etag +If-Modified-Since: $now foo +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 412 } ]; +ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + Last-Modified + overlong timestamp'); + +ok($tf->stop_proc == 0, "Stopping lighttpd"); + |