Mercurial > hg > nginx-tests
diff ignore_invalid_headers.t @ 1715:3604ef83c1aa
Tests: added header name tests with forbidden characters.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 29 Jun 2021 12:00:07 +0300 |
parents | 5ac6efbe5552 |
children | 2a0a6035a1af |
line wrap: on
line diff
--- a/ignore_invalid_headers.t +++ b/ignore_invalid_headers.t @@ -25,7 +25,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(9) +my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(12) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -116,6 +116,24 @@ unlike(get($us2, 8081), qr/x-bar/, 'on - like(get($us, 8082), qr/x-bar/, 'underscores_in_headers'); like(get($us2, 8082), qr/x-bar/, 'underscores_in_headers - first'); +# always invalid header characters + +my $bad3 = 'GET / HTTP/1.0' . CRLF + . ':foo: x-bar' . CRLF . CRLF; +my $bad4 = 'GET / HTTP/1.0' . CRLF + . ' foo: x-bar' . CRLF . CRLF; +my $bad5 = 'GET / HTTP/1.0' . CRLF + . "foo\x02: x-bar" . CRLF . CRLF; + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.21.1'); + +like(http($bad3), qr/400 Bad/, 'colon first'); +like(http($bad4), qr/400 Bad/, 'space'); +like(http($bad5), qr/400 Bad/, 'control'); + +} + ############################################################################### sub get {