comparison proxy_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 e9064d691790
comparison
equal deleted inserted replaced
836:a9c4cebcfe69 837:68a6678abae2
205 local $SIG{PIPE} = sub { die "sigpipe\n" }; 205 local $SIG{PIPE} = sub { die "sigpipe\n" };
206 alarm(5); 206 alarm(5);
207 207
208 $client = $server->accept(); 208 $client = $server->accept();
209 209
210 log2c("(new connection $client)");
211
210 alarm(0); 212 alarm(0);
211 }; 213 };
212 alarm(0); 214 alarm(0);
213 if ($@) { 215 if ($@) {
214 log_in("died: $@"); 216 log_in("died: $@");
215 return undef; 217 return undef;
216 } 218 }
217 219
218 $client->sysread(my $buf, 1024); 220 $client->sysread(my $buf, 1024);
221 log2i($buf);
222
219 $buf =~ s/.*?\x0d\x0a?\x0d\x0a?(.*)/$1/ms; 223 $buf =~ s/.*?\x0d\x0a?\x0d\x0a?(.*)/$1/ms;
220 224
221 my $f = { preread => $buf }; 225 my $f = { preread => $buf };
222 $f->{upload} = sub { 226 $f->{upload} = sub {
223 my $buf = shift; 227 my $buf = shift;
225 eval { 229 eval {
226 local $SIG{ALRM} = sub { die "timeout\n" }; 230 local $SIG{ALRM} = sub { die "timeout\n" };
227 local $SIG{PIPE} = sub { die "sigpipe\n" }; 231 local $SIG{PIPE} = sub { die "sigpipe\n" };
228 alarm(5); 232 alarm(5);
229 233
234 log_out($buf);
230 $s->write($buf); 235 $s->write($buf);
236
231 $client->sysread($buf, 1024); 237 $client->sysread($buf, 1024);
238 log2i($buf);
232 239
233 alarm(0); 240 alarm(0);
234 }; 241 };
235 alarm(0); 242 alarm(0);
236 if ($@) { 243 if ($@) {
257 local $SIG{ALRM} = sub { die "timeout\n" }; 264 local $SIG{ALRM} = sub { die "timeout\n" };
258 local $SIG{PIPE} = sub { die "sigpipe\n" }; 265 local $SIG{PIPE} = sub { die "sigpipe\n" };
259 alarm(5); 266 alarm(5);
260 267
261 $s->sysread($buf, 1024); 268 $s->sysread($buf, 1024);
269 log_in($buf);
262 270
263 alarm(0); 271 alarm(0);
264 }; 272 };
265 alarm(0); 273 alarm(0);
266 if ($@) { 274 if ($@) {
271 return $buf; 279 return $buf;
272 }; 280 };
273 return $f; 281 return $f;
274 } 282 }
275 283
276 ############################################################################### 284 sub log2i { Test::Nginx::log_core('|| <<', @_); }
285 sub log2o { Test::Nginx::log_core('|| >>', @_); }
286 sub log2c { Test::Nginx::log_core('||', @_); }
287
288 ###############################################################################