comparison image_filter.t @ 908:adf5671391ac

Tests: use read_file subroutine in several tests.
author Andrey Zelenkov <zelenkov@nginx.com>
date Mon, 18 Apr 2016 19:29:57 +0300
parents a0bcdc51d99b
children e9064d691790
comparison
equal deleted inserted replaced
907:44f37197181f 908:adf5671391ac
174 $t->write_file('jpeg', $im->jpeg); 174 $t->write_file('jpeg', $im->jpeg);
175 $t->write_file('gif', $im->gif); 175 $t->write_file('gif', $im->gif);
176 $t->write_file('png', $im->png); 176 $t->write_file('png', $im->png);
177 $t->write_file('txt', 'SEE-THIS'); 177 $t->write_file('txt', 'SEE-THIS');
178 178
179 $t->run_daemon(\&http_daemon, $t->testdir()); 179 $t->run_daemon(\&http_daemon, $t);
180 $t->run()->waitforsocket('127.0.0.1:8081'); 180 $t->run()->waitforsocket('127.0.0.1:8081');
181 181
182 ############################################################################### 182 ###############################################################################
183 183
184 like(http_head('/test/gif'), qr/200 OK/, 'test'); 184 like(http_head('/test/gif'), qr/200 OK/, 'test');
296 ############################################################################### 296 ###############################################################################
297 297
298 # serve static files without Content-Length 298 # serve static files without Content-Length
299 299
300 sub http_daemon { 300 sub http_daemon {
301 my ($root) = @_; 301 my ($t) = @_;
302 302
303 my $server = IO::Socket::INET->new( 303 my $server = IO::Socket::INET->new(
304 Proto => 'tcp', 304 Proto => 'tcp',
305 LocalHost => '127.0.0.1', 305 LocalHost => '127.0.0.1',
306 LocalPort => 8081, 306 LocalPort => 8081,
322 last if (/^\x0d?\x0a?$/); 322 last if (/^\x0d?\x0a?$/);
323 } 323 }
324 324
325 next if $headers eq ''; 325 next if $headers eq '';
326 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; 326 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
327 327 my $data = $t->read_file($uri);
328 open my $fh, '<', $root . $uri or next;
329 local $/;
330 my $data = <$fh>;
331 close $fh;
332 328
333 print $client <<EOF; 329 print $client <<EOF;
334 HTTP/1.1 200 OK 330 HTTP/1.1 200 OK
335 Connection: close 331 Connection: close
336 332