comparison scgi_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
24 24
25 eval { require SCGI; }; 25 eval { require SCGI; };
26 plan(skip_all => 'SCGI not installed') if $@; 26 plan(skip_all => 'SCGI not installed') if $@;
27 27
28 my $t = Test::Nginx->new() 28 my $t = Test::Nginx->new()
29 ->has(qw/http scgi cache rewrite addition/)->plan(20) 29 ->has(qw/http scgi cache rewrite addition/)->plan(22)
30 ->write_file_expand('nginx.conf', <<'EOF'); 30 ->write_file_expand('nginx.conf', <<'EOF');
31 31
32 %%TEST_GLOBALS%% 32 %%TEST_GLOBALS%%
33 33
34 daemon off; 34 daemon off;
132 'head extra cached'); 132 'head extra cached');
133 like(http_get('/head/short'), qr/SEE-THIS(?!.*:after)/s, 133 like(http_get('/head/short'), qr/SEE-THIS(?!.*:after)/s,
134 'head too short cached'); 134 'head too short cached');
135 135
136 } 136 }
137
138 # "zero size buf" alerts (ticket #2117)
139
140 TODO: {
141 local $TODO = 'not yet' unless $t->has_version('1.19.1');
142
143 like(http_get('/zero'), qr/200 OK(?!.*NOT-THIS)/s, 'zero size');
144
145 }
146
147 TODO: {
148 local $TODO = 'not yet';
149
150 like(http_get('/unbuf/zero'), qr/200 OK(?!.*NOT-THIS)/s,
151 'unbuffered zero size');
152
153 }
154
155 $t->todo_alerts() if $t->has_version('1.19.1');
137 156
138 ############################################################################### 157 ###############################################################################
139 158
140 sub scgi_daemon { 159 sub scgi_daemon {
141 my $server = IO::Socket::INET->new( 160 my $server = IO::Socket::INET->new(
163 if ($uri eq '/') { 182 if ($uri eq '/') {
164 $c->print("Content-Type: text/html\n"); 183 $c->print("Content-Type: text/html\n");
165 $c->print("Content-Length: 8\n\n"); 184 $c->print("Content-Length: 8\n\n");
166 $c->print("SEE-THIS-BUT-NOT-THIS\n"); 185 $c->print("SEE-THIS-BUT-NOT-THIS\n");
167 186
187 } elsif ($uri eq '/zero') {
188 $c->print("Content-Type: text/html\n");
189 $c->print("Content-Length: 0\n\n");
190 $c->print("NOT-THIS\n");
191
168 } elsif ($uri eq '/short') { 192 } elsif ($uri eq '/short') {
169 $c->print("Content-Type: text/html\n"); 193 $c->print("Content-Type: text/html\n");
170 $c->print("Content-Length: 100\n\n"); 194 $c->print("Content-Length: 100\n\n");
171 $c->print("SEE-THIS-TOO-SHORT-RESPONSE\n"); 195 $c->print("SEE-THIS-TOO-SHORT-RESPONSE\n");
172 196