comparison lib/Test/Nginx.pm @ 79:d5330d926fac

Tests: add test for limit_req not clearing write timeout on delay.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 28 Mar 2009 16:13:07 +0300
parents ff5f4f298532
children f2d09159a8f3
comparison
equal deleted inserted replaced
78:c893908c1a44 79:d5330d926fac
226 log_core('<<', @_); 226 log_core('<<', @_);
227 } 227 }
228 228
229 ############################################################################### 229 ###############################################################################
230 230
231 sub http_get($) { 231 sub http_get($;%) {
232 my ($url) = @_; 232 my ($url, %extra) = @_;
233 return http(<<EOF); 233 return http(<<EOF, %extra);
234 GET $url HTTP/1.0 234 GET $url HTTP/1.0
235 Host: localhost 235 Host: localhost
236 236
237 EOF 237 EOF
238 } 238 }
239 239
240 sub http_head($) { 240 sub http_head($;%) {
241 my ($url) = @_; 241 my ($url, %extra) = @_;
242 return http(<<EOF); 242 return http(<<EOF, %extra);
243 HEAD $url HTTP/1.0 243 HEAD $url HTTP/1.0
244 Host: localhost 244 Host: localhost
245 245
246 EOF 246 EOF
247 } 247 }
248 248
249 sub http($) { 249 sub http($;%) {
250 my ($request) = @_; 250 my ($request, %extra) = @_;
251 my $reply; 251 my $reply;
252 eval { 252 eval {
253 local $SIG{ALRM} = sub { die "alarm\n" }; 253 local $SIG{ALRM} = sub { die "alarm\n" };
254 alarm(2); 254 alarm(2);
255 my $s = IO::Socket::INET->new( 255 my $s = IO::Socket::INET->new(
257 PeerAddr => '127.0.0.1:8080' 257 PeerAddr => '127.0.0.1:8080'
258 ); 258 );
259 log_out($request); 259 log_out($request);
260 $s->print($request); 260 $s->print($request);
261 local $/; 261 local $/;
262 select undef, undef, undef, $extra{sleep} if $extra{sleep};
262 $reply = $s->getline(); 263 $reply = $s->getline();
263 log_in($reply); 264 log_in($reply);
264 alarm(0); 265 alarm(0);
265 }; 266 };
266 alarm(0); 267 alarm(0);