Plack-Middleware-Image-Scale
view release on metacpan or search on metacpan
t/02_responsetypes.t view on Meta::CPAN
]);
};
} elsif ( $env->{PATH_INFO} eq '/delayedfilehandle.png' ) {
return sub { shift->([
200,
[ 'Content-Type' => 'image/png' ],
IO::File->new($fname,'<')
]) };
} elsif ( $env->{PATH_INFO} eq '/streaming.png' ) {
return sub {
my $writer = shift->(
[ 200, ['Content-Type' => 'image/png'] ]
);
my $fh = IO::File->new($fname,'<');
while( $fh->read(my $buf,10) ) {
$writer->write($buf);
}
$writer->close;
};
} elsif ( $env->{PATH_INFO} eq '/streaming-empty-304.png' ) {
return sub {
my $writer = shift->(
[ 304, ['Content-Type' => 'image/png'] ]
);
$writer->close;
};
}
return [404,['Content-Type','text/plain'],[]];
};
t/02_responsetypes.t view on Meta::CPAN
};
subtest 'delayed filehandle response' => sub {
my $res = $cb->(GET "http://localhost/delayedfilehandle_200x200.png");
is $res->code, 200, 'Response HTTP status';
is $res->content_type, 'image/png', 'Response Content-Type';
};
subtest 'streaming response' => sub {
my $res = $cb->(GET "http://localhost/streaming_200x200.png");
is $res->code, 200, 'Response HTTP status';
is $res->content_type, 'image/png', 'Response Content-Type';
};
subtest 'streaming empty 304 response' => sub {
my $res = $cb->(GET "http://localhost/streaming-empty-304_200x200.png");
is $res->code, 304, 'Response HTTP status';
is $res->content_type, 'image/png', 'Response Content-Type';
is $res->content, '', 'Response body is empty';
};
};
done_testing;
( run in 0.281 second using v1.01-cache-2.11-cpan-4d50c553e7e )