changeset 1551:27237569776f

Tests: additional Transfer-Encoding and Host headers tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 27 Feb 2020 19:49:54 +0300
parents 5c96745988c4
children 3b6b2667ece9
files body_chunked.t http_host.t
diffstat 2 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/body_chunked.t
+++ b/body_chunked.t
@@ -22,7 +22,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(13);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(16);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -172,6 +172,22 @@ like(
 like(http_get_body('/next', '0123456789'),
 	qr/X-Body: 0123456789\x0d?$/ms, 'body chunked next upstream');
 
+# invalid Transfer-Encoding
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.17.9');
+
+like(http_transfer_encoding('identity'), qr/501 Not Implemented/,
+	'transfer encoding identity');
+
+like(http_transfer_encoding("chunked\nTransfer-Encoding: chunked"),
+	qr/400 Bad/, 'transfer encoding repeat');
+
+}
+
+like(http_transfer_encoding('chunked, identity'), qr/501 Not Implemented/,
+	'transfer encoding list');
+
 ###############################################################################
 
 sub read_body_file {
@@ -207,4 +223,14 @@ sub http_get_body {
 	);
 }
 
+sub http_transfer_encoding {
+	my ($encoding) = @_;
+
+	http("GET / HTTP/1.1" . CRLF
+		. "Host: localhost" . CRLF
+		. "Connection: close" . CRLF
+		. "Transfer-Encoding: $encoding" . CRLF . CRLF
+		. "0" . CRLF . CRLF);
+}
+
 ###############################################################################
--- a/http_host.t
+++ b/http_host.t
@@ -22,7 +22,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(35);
+my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(36);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -169,6 +169,13 @@ is(http_absolute_path(
 is(http_host_header('123.40.56.78:9000:80'), '123.40.56.78',
 	'double port hack');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.17.9');
+
+like(http_host_header("localhost\nHost: again", 1), qr/ 400 /, 'host repeat');
+
+}
+
 ###############################################################################
 
 sub http_host_header {