AnyEvent-MultiDownload
view release on metacpan or search on metacpan
t/01_simple_get.t view on Meta::CPAN
{
package HTTP::Server::Simple::Test;
our @ISA = 'HTTP::Server::Simple::CGI';
sub print_banner { }
sub handle_request {
my ($self, $cgi) = @_;
if($cgi->url(-path_info=>1) =~ m,/error$,) {
print "HTTP/1.0 404 Not found\r\n";
print "Content-Type: text/plain\r\n";
print "\r\n";
print "404 Not found";
return;
}
my $body =
"a" x 1024 . "b" x 1024 .
"c" x 1024 . "d" x 1024 .
"e" x 1024 . "f" x 1024 .
"g" x 1024 . "h" x 1024;
my %map = (
t/02_exception_nofind.t view on Meta::CPAN
{
package HTTP::Server::Simple::Test;
our @ISA = 'HTTP::Server::Simple::CGI';
sub print_banner { }
sub handle_request {
my ($self, $cgi) = @_;
if($cgi->url(-path_info=>1) =~ m,/notfind$,) {
print "HTTP/1.0 404 Not found\r\n";
print "Content-Type: text/plain\r\n";
print "\r\n";
print "404 Not found";
return;
}
}
}
Test::TCP::test_tcp(
server => sub {
my $port = shift;
my $server = HTTP::Server::Simple::Test->new($port);
$server->run;
t/02_exception_nofind.t view on Meta::CPAN
my $cv = AE::cv;
my $MultiDown = AnyEvent::MultiDownload->new(
url => "http://localhost:$port/notfind",
path => "$path.1",
on_finish => sub {
my $len = shift;
$cv->send;
},
on_error => sub {
my ($error, $hdr) = @_;
is $error, 'Status: 404, Reason: Not found.', 'error info';
is $hdr->{Status}, 404, 'header 404';
$cv->send;
}
)->start;
$cv->recv;
unlink $path;
}
},
);
( run in 1.591 second using v1.01-cache-2.11-cpan-39bf76dae61 )