Mercurial > hg > nginx-tests
comparison proxy_request_buffering_chunked.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 | e9064d691790 |
comparison
equal
deleted
inserted
replaced
836:a9c4cebcfe69 | 837:68a6678abae2 |
---|---|
240 local $SIG{PIPE} = sub { die "sigpipe\n" }; | 240 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
241 alarm(5); | 241 alarm(5); |
242 | 242 |
243 $client = $server->accept(); | 243 $client = $server->accept(); |
244 | 244 |
245 log2c("(new connection $client)"); | |
246 | |
245 alarm(0); | 247 alarm(0); |
246 }; | 248 }; |
247 alarm(0); | 249 alarm(0); |
248 if ($@) { | 250 if ($@) { |
249 log_in("died: $@"); | 251 log_in("died: $@"); |
250 return undef; | 252 return undef; |
251 } | 253 } |
252 | 254 |
253 $client->sysread(my $buf, 1024); | 255 $client->sysread(my $buf, 1024); |
256 log2i($buf); | |
257 | |
254 $buf =~ s/.*?\x0d\x0a?\x0d\x0a?(.*)/$1/ms; | 258 $buf =~ s/.*?\x0d\x0a?\x0d\x0a?(.*)/$1/ms; |
255 | 259 |
256 my $f = { preread => $buf }; | 260 my $f = { preread => $buf }; |
257 $f->{upload} = sub { | 261 $f->{upload} = sub { |
258 my ($body, %extra) = @_; | 262 my ($body, %extra) = @_; |
274 eval { | 278 eval { |
275 local $SIG{ALRM} = sub { die "timeout\n" }; | 279 local $SIG{ALRM} = sub { die "timeout\n" }; |
276 local $SIG{PIPE} = sub { die "sigpipe\n" }; | 280 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
277 alarm(5); | 281 alarm(5); |
278 | 282 |
283 log_out($buf); | |
279 $s->write($buf); | 284 $s->write($buf); |
285 | |
280 $client->sysread($buf, 1024); | 286 $client->sysread($buf, 1024); |
287 log2i($buf); | |
281 | 288 |
282 alarm(0); | 289 alarm(0); |
283 }; | 290 }; |
284 alarm(0); | 291 alarm(0); |
285 if ($@) { | 292 if ($@) { |
306 local $SIG{ALRM} = sub { die "timeout\n" }; | 313 local $SIG{ALRM} = sub { die "timeout\n" }; |
307 local $SIG{PIPE} = sub { die "sigpipe\n" }; | 314 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
308 alarm(5); | 315 alarm(5); |
309 | 316 |
310 $s->sysread($buf, 1024); | 317 $s->sysread($buf, 1024); |
318 log_in($buf); | |
319 | |
311 $s->close(); | 320 $s->close(); |
312 | 321 |
313 alarm(0); | 322 alarm(0); |
314 }; | 323 }; |
315 alarm(0); | 324 alarm(0); |
321 return $buf; | 330 return $buf; |
322 }; | 331 }; |
323 return $f; | 332 return $f; |
324 } | 333 } |
325 | 334 |
326 ############################################################################### | 335 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
336 sub log2o { Test::Nginx::log_core('|| >>', @_); } | |
337 sub log2c { Test::Nginx::log_core('||', @_); } | |
338 | |
339 ############################################################################### |