comparison fastcgi_request_buffering.t @ 837:68a6678abae2

Tests: improved logging for unbuffered request body tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 29 Jan 2016 16:12:42 +0300
parents 907e89fba9c3
children 6bb1f2ccd386
comparison
equal deleted inserted replaced
836:a9c4cebcfe69 837:68a6678abae2
239 local $SIG{PIPE} = sub { die "sigpipe\n" }; 239 local $SIG{PIPE} = sub { die "sigpipe\n" };
240 alarm(5); 240 alarm(5);
241 241
242 $client = $server->accept(); 242 $client = $server->accept();
243 243
244 log2c("(new connection $client)");
245
244 alarm(0); 246 alarm(0);
245 }; 247 };
246 alarm(0); 248 alarm(0);
247 if ($@) { 249 if ($@) {
248 log_in("died: $@"); 250 log_in("died: $@");
249 return undef; 251 return undef;
250 } 252 }
251 253
252 $client->sysread(my $buf, 1024); 254 $client->sysread(my $buf, 1024);
255 log2i($buf);
256
253 $body = ''; 257 $body = '';
254 258
255 while (my $h = fastcgi_read_record(\$buf)) { 259 while (my $h = fastcgi_read_record(\$buf)) {
256 $version = $h->{version}; 260 $version = $h->{version};
257 $id = $h->{id}; 261 $id = $h->{id};
269 eval { 273 eval {
270 local $SIG{ALRM} = sub { die "timeout\n" }; 274 local $SIG{ALRM} = sub { die "timeout\n" };
271 local $SIG{PIPE} = sub { die "sigpipe\n" }; 275 local $SIG{PIPE} = sub { die "sigpipe\n" };
272 alarm(5); 276 alarm(5);
273 277
278 log_out($buf);
274 $s->write($buf); 279 $s->write($buf);
280
275 $client->sysread($buf, 1024); 281 $client->sysread($buf, 1024);
282 log2i($buf);
283
276 $body = ''; 284 $body = '';
277 285
278 while (my $h = fastcgi_read_record(\$buf)) { 286 while (my $h = fastcgi_read_record(\$buf)) {
279 287
280 # skip everything unless stdin 288 # skip everything unless stdin
310 local $SIG{ALRM} = sub { die "timeout\n" }; 318 local $SIG{ALRM} = sub { die "timeout\n" };
311 local $SIG{PIPE} = sub { die "sigpipe\n" }; 319 local $SIG{PIPE} = sub { die "sigpipe\n" };
312 alarm(5); 320 alarm(5);
313 321
314 $s->sysread($buf, 1024); 322 $s->sysread($buf, 1024);
323 log_in($buf);
315 324
316 alarm(0); 325 alarm(0);
317 }; 326 };
318 alarm(0); 327 alarm(0);
319 if ($@) { 328 if ($@) {
324 return $buf; 333 return $buf;
325 }; 334 };
326 return $f; 335 return $f;
327 } 336 }
328 337
338 sub log2i { Test::Nginx::log_core('|| <<', @_); }
339 sub log2o { Test::Nginx::log_core('|| >>', @_); }
340 sub log2c { Test::Nginx::log_core('||', @_); }
341
329 ############################################################################### 342 ###############################################################################
330 343
331 sub fastcgi_daemon { 344 sub fastcgi_daemon {
332 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5); 345 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5);
333 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, 346 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,