# HG changeset patch # User Sergey Kandaurov # Date 1582822194 -10800 # Node ID 27237569776f59b088198d70aaa9bd093c5b9014 # Parent 5c96745988c41f5d36eea9708c66ede7e6163c72 Tests: additional Transfer-Encoding and Host headers tests. diff --git a/body_chunked.t b/body_chunked.t --- 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); +} + ############################################################################### diff --git a/http_host.t b/http_host.t --- 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 {