summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9>2012-11-21 12:01:42 +0000
committerstbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9>2012-11-21 12:01:42 +0000
commit8dbfe3fef00e6243028fa93fbe285bf94d63a0b6 (patch)
treebc8d93208b265934197b83585976f78c3b62f925
parenta443d7e1f92f2359adc9e7e1a25e6b15224f4cbf (diff)
downloadlighttpd-8dbfe3fef00e6243028fa93fbe285bf94d63a0b6.tar.gz
tests: check different combination of empty values, leading/trailing spaces and commas in the Connection header
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2859 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--tests/CMakeLists.txt2
-rwxr-xr-xtests/request.t58
2 files changed, 58 insertions, 2 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e8082497..40ef370f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -27,7 +27,7 @@ SET(T_FILES
)
FOREACH(it ${T_FILES})
- ADD_TEST(${it} "${lighttpd_SOURCE_DIR}/tests/wrapper.sh"
+ ADD_TEST(NAME ${it} COMMAND "${lighttpd_SOURCE_DIR}/tests/wrapper.sh"
"${lighttpd_SOURCE_DIR}/tests"
"${lighttpd_BINARY_DIR}"
"${lighttpd_SOURCE_DIR}/tests/${it}")
diff --git a/tests/request.t b/tests/request.t
index c4bd9581..93589751 100755
--- a/tests/request.t
+++ b/tests/request.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
use IO::Socket;
-use Test::More tests => 46;
+use Test::More tests => 52;
use LightyTest;
my $tf = LightyTest->new();
@@ -429,5 +429,61 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
ok($tf->handle_http($t) == 0, 'static file with forbidden pathinfo');
+
+print "\nConnection header\n";
+$t->{REQUEST} = ( <<EOF
+GET /12345.txt HTTP/1.1
+Connection : close
+Host: 123.example.org
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
+ok($tf->handle_http($t) == 0, 'Connection-header, spaces before ":"');
+
+$t->{REQUEST} = ( <<EOF
+GET /12345.txt HTTP/1.1
+Connection: ,close
+Host: 123.example.org
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
+ok($tf->handle_http($t) == 0, 'Connection-header, leading comma');
+
+$t->{REQUEST} = ( <<EOF
+GET /12345.txt HTTP/1.1
+Connection: close,,TE
+Host: 123.example.org
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
+ok($tf->handle_http($t) == 0, 'Connection-header, no value between two commas');
+
+$t->{REQUEST} = ( <<EOF
+GET /12345.txt HTTP/1.1
+Connection: close, ,TE
+Host: 123.example.org
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
+ok($tf->handle_http($t) == 0, 'Connection-header, space between two commas');
+
+$t->{REQUEST} = ( <<EOF
+GET /12345.txt HTTP/1.1
+Connection: close,
+Host: 123.example.org
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
+ok($tf->handle_http($t) == 0, 'Connection-header, comma after value');
+
+$t->{REQUEST} = ( <<EOF
+GET /12345.txt HTTP/1.1
+Connection: close,
+Host: 123.example.org
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
+ok($tf->handle_http($t) == 0, 'Connection-header, comma and space after value');
+
ok($tf->stop_proc == 0, "Stopping lighttpd");