# HG changeset patch # User Maxim Dounin # Date 1610389954 -10800 # Node ID 6128590b0d462701c1aeec68dc77f8f478075abd # Parent da52525f49d109a7a3857b0986bd81509a3d6043 Tests: tests for "zero size buf" alerts in unbuffered proxying. Starting with nginx 1.19.1, non-buffered simple proxying of responses with expected length 0 but some extra data might result in zero size buffers being generated and "zero size buf" alerts in writer (ticket #2117). Tests for a similar bug in FastCGI proxying are in 1586:e145509cc6eb. diff --git a/proxy_extra_data.t b/proxy_extra_data.t --- a/proxy_extra_data.t +++ b/proxy_extra_data.t @@ -23,7 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; my $t = Test::Nginx->new() - ->has(qw/http proxy cache rewrite addition/)->plan(20) + ->has(qw/http proxy cache rewrite addition/)->plan(22) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -131,6 +131,26 @@ like(http_get('/head/extra'), qr/SEE-THI like(http_get('/head/short'), qr/SEE-THIS(?!.*:after)/s, 'head too short cached'); + +# "zero size buf" alerts (ticket #2117) + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.19.1'); + +like(http_get('/zero'), qr/200 OK(?!.*NOT-THIS)/s, 'zero size'); + +} + +TODO: { +local $TODO = 'not yet'; + +like(http_get('/unbuf/zero'), qr/200 OK(?!.*NOT-THIS)/s, + 'unbuffered zero size'); + +} + +$t->todo_alerts() if $t->has_version('1.19.1'); + ############################################################################### sub http_daemon { @@ -168,6 +188,12 @@ sub http_daemon { $c->print("Content-Length: 8\n\n"); $c->print("SEE-THIS-BUT-NOT-THIS\n"); + } elsif ($uri eq '/zero') { + $c->print("HTTP/1.1 200 OK\n"); + $c->print("Content-Type: text/html\n"); + $c->print("Content-Length: 0\n\n"); + $c->print("NOT-THIS\n"); + } elsif ($uri eq '/short') { $c->print("HTTP/1.1 200 OK\n"); $c->print("Content-Type: text/html\n"); diff --git a/scgi_extra_data.t b/scgi_extra_data.t --- a/scgi_extra_data.t +++ b/scgi_extra_data.t @@ -26,7 +26,7 @@ eval { require SCGI; }; plan(skip_all => 'SCGI not installed') if $@; my $t = Test::Nginx->new() - ->has(qw/http scgi cache rewrite addition/)->plan(20) + ->has(qw/http scgi cache rewrite addition/)->plan(22) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -135,6 +135,25 @@ like(http_get('/head/short'), qr/SEE-THI } +# "zero size buf" alerts (ticket #2117) + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.19.1'); + +like(http_get('/zero'), qr/200 OK(?!.*NOT-THIS)/s, 'zero size'); + +} + +TODO: { +local $TODO = 'not yet'; + +like(http_get('/unbuf/zero'), qr/200 OK(?!.*NOT-THIS)/s, + 'unbuffered zero size'); + +} + +$t->todo_alerts() if $t->has_version('1.19.1'); + ############################################################################### sub scgi_daemon { @@ -165,6 +184,11 @@ sub scgi_daemon { $c->print("Content-Length: 8\n\n"); $c->print("SEE-THIS-BUT-NOT-THIS\n"); + } elsif ($uri eq '/zero') { + $c->print("Content-Type: text/html\n"); + $c->print("Content-Length: 0\n\n"); + $c->print("NOT-THIS\n"); + } elsif ($uri eq '/short') { $c->print("Content-Type: text/html\n"); $c->print("Content-Length: 100\n\n");