Tests: additional Transfer-Encoding and Host headers tests.
diff --git a/body_chunked.t b/body_chunked.t index 1520d5b..549d4cc 100644 --- a/body_chunked.t +++ b/body_chunked.t
@@ -22,7 +22,7 @@ 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(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_transfer_encoding { + my ($encoding) = @_; + + http("GET / HTTP/1.1" . CRLF + . "Host: localhost" . CRLF + . "Connection: close" . CRLF + . "Transfer-Encoding: $encoding" . CRLF . CRLF + . "0" . CRLF . CRLF); +} + ###############################################################################
diff --git a/http_host.t b/http_host.t index d3a4df9..7bd0dcc 100644 --- a/http_host.t +++ b/http_host.t
@@ -22,7 +22,7 @@ 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_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 {