Subject: | Hangs on multiple requests |
If I use the attached to try various combinations of URLs it seems to hang after the first URL. For example, if I do:
perl net-async-http_test.pl http://192.168.1.2/page1.html
it works. But if I do these it hangs:
perl net-async-http_test.pl http://192.168.1.2/page1.html http://192.168.1.2/page2.html
perl net-async-http_test.pl http://192.168.1.2/page1.html http://192.168.1.2/page1.html
Note that 192.168.1.2 is a local pretty much vanilla apache server (but that does apparently do a close after each request). If I use a public 1.1 server that doesn't do a close after requests it works.
Oh, and discussed with paule on IRC (but documenting here) :-) if you change the
constructor call to Net::Async::HTTP to this it works:
my $http = Net::Async::HTTP->new(max_connections_per_host => 0);
Thanks!
Subject: | net-async-http_test.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use IO::Async::Loop;
use Net::Async::HTTP;
die "At least one URL on cmd line required\n" unless scalar(@ARGV);
my $loop = IO::Async::Loop->new;
my $http = Net::Async::HTTP->new;
$loop->add($http);
sub GET {
my ($url) = @_;
print "Getting: $url\n";
return $http->GET($url);
}
my $f = Future->needs_all(
map { GET($_) } @ARGV
)->on_done( sub{
print "\nDone!\n\n";
});
$f->get;