diff body_chunked.t @ 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 5ae8e8feac36
children 5ac6efbe5552
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);
+}
+
 ###############################################################################