comparison proxy_request_buffering_ssl.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
226 local $SIG{PIPE} = sub { die "sigpipe\n" }; 226 local $SIG{PIPE} = sub { die "sigpipe\n" };
227 alarm(5); 227 alarm(5);
228 228
229 $client = $server->accept(); 229 $client = $server->accept();
230 230
231 log2c("(new connection $client)");
232
231 alarm(0); 233 alarm(0);
232 }; 234 };
233 alarm(0); 235 alarm(0);
234 if ($@) { 236 if ($@) {
235 log_in("died: $@"); 237 log_in("died: $@");
236 return undef; 238 return undef;
237 } 239 }
238 240
239 $client->sysread(my $buf, 1024); 241 $client->sysread(my $buf, 1024);
242 log2i($buf);
243
240 $buf =~ s/.*?\x0d\x0a?\x0d\x0a?(.*)/$1/ms; 244 $buf =~ s/.*?\x0d\x0a?\x0d\x0a?(.*)/$1/ms;
241 245
242 my $f = { preread => $buf }; 246 my $f = { preread => $buf };
243 $f->{upload} = sub { 247 $f->{upload} = sub {
244 my $buf = shift; 248 my $buf = shift;
246 eval { 250 eval {
247 local $SIG{ALRM} = sub { die "timeout\n" }; 251 local $SIG{ALRM} = sub { die "timeout\n" };
248 local $SIG{PIPE} = sub { die "sigpipe\n" }; 252 local $SIG{PIPE} = sub { die "sigpipe\n" };
249 alarm(5); 253 alarm(5);
250 254
255 log_out($buf);
251 $s->write($buf); 256 $s->write($buf);
257
252 $client->sysread($buf, 1024); 258 $client->sysread($buf, 1024);
259 log2i($buf);
253 260
254 alarm(0); 261 alarm(0);
255 }; 262 };
256 alarm(0); 263 alarm(0);
257 if ($@) { 264 if ($@) {
278 local $SIG{ALRM} = sub { die "timeout\n" }; 285 local $SIG{ALRM} = sub { die "timeout\n" };
279 local $SIG{PIPE} = sub { die "sigpipe\n" }; 286 local $SIG{PIPE} = sub { die "sigpipe\n" };
280 alarm(5); 287 alarm(5);
281 288
282 $s->sysread($buf, 1024); 289 $s->sysread($buf, 1024);
290 log_in($buf);
283 291
284 alarm(0); 292 alarm(0);
285 }; 293 };
286 alarm(0); 294 alarm(0);
287 if ($@) { 295 if ($@) {
292 return $buf; 300 return $buf;
293 }; 301 };
294 return $f; 302 return $f;
295 } 303 }
296 304
297 ############################################################################### 305 sub log2i { Test::Nginx::log_core('|| <<', @_); }
306 sub log2o { Test::Nginx::log_core('|| >>', @_); }
307 sub log2c { Test::Nginx::log_core('||', @_); }
308
309 ###############################################################################