comparison proxy_extra_data.t @ 1638:6128590b0d46

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 11 Jan 2021 21:32:34 +0300
parents 463d6863d360
children 6c323c672a86
comparison
equal deleted inserted replaced
1637:da52525f49d1 1638:6128590b0d46
21 21
22 select STDERR; $| = 1; 22 select STDERR; $| = 1;
23 select STDOUT; $| = 1; 23 select STDOUT; $| = 1;
24 24
25 my $t = Test::Nginx->new() 25 my $t = Test::Nginx->new()
26 ->has(qw/http proxy cache rewrite addition/)->plan(20) 26 ->has(qw/http proxy cache rewrite addition/)->plan(22)
27 ->write_file_expand('nginx.conf', <<'EOF'); 27 ->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
31 daemon off; 31 daemon off;
128 128
129 } 129 }
130 130
131 like(http_get('/head/short'), qr/SEE-THIS(?!.*:after)/s, 131 like(http_get('/head/short'), qr/SEE-THIS(?!.*:after)/s,
132 'head too short cached'); 132 'head too short cached');
133
134
135 # "zero size buf" alerts (ticket #2117)
136
137 TODO: {
138 local $TODO = 'not yet' unless $t->has_version('1.19.1');
139
140 like(http_get('/zero'), qr/200 OK(?!.*NOT-THIS)/s, 'zero size');
141
142 }
143
144 TODO: {
145 local $TODO = 'not yet';
146
147 like(http_get('/unbuf/zero'), qr/200 OK(?!.*NOT-THIS)/s,
148 'unbuffered zero size');
149
150 }
151
152 $t->todo_alerts() if $t->has_version('1.19.1');
133 153
134 ############################################################################### 154 ###############################################################################
135 155
136 sub http_daemon { 156 sub http_daemon {
137 my $server = IO::Socket::INET->new( 157 my $server = IO::Socket::INET->new(
166 $c->print("HTTP/1.1 200 OK\n"); 186 $c->print("HTTP/1.1 200 OK\n");
167 $c->print("Content-Type: text/html\n"); 187 $c->print("Content-Type: text/html\n");
168 $c->print("Content-Length: 8\n\n"); 188 $c->print("Content-Length: 8\n\n");
169 $c->print("SEE-THIS-BUT-NOT-THIS\n"); 189 $c->print("SEE-THIS-BUT-NOT-THIS\n");
170 190
191 } elsif ($uri eq '/zero') {
192 $c->print("HTTP/1.1 200 OK\n");
193 $c->print("Content-Type: text/html\n");
194 $c->print("Content-Length: 0\n\n");
195 $c->print("NOT-THIS\n");
196
171 } elsif ($uri eq '/short') { 197 } elsif ($uri eq '/short') {
172 $c->print("HTTP/1.1 200 OK\n"); 198 $c->print("HTTP/1.1 200 OK\n");
173 $c->print("Content-Type: text/html\n"); 199 $c->print("Content-Type: text/html\n");
174 $c->print("Content-Length: 100\n\n"); 200 $c->print("Content-Length: 100\n\n");
175 $c->print("SEE-THIS-TOO-SHORT-RESPONSE\n"); 201 $c->print("SEE-THIS-TOO-SHORT-RESPONSE\n");