evdb / HTTP-Async

process multiple HTTP requests in parallel without blocking
http://search.cpan.org/dist/HTTP-Async/lib/HTTP/Async.pm
8 stars 14 forks source link

Test failures on IPv6 systems #19

Open richardleach opened 6 years ago

richardleach commented 6 years ago

Hi,

Three HTTP::Async test files establish a listening HTTP service using IO::Socket::INET, attempt to test that service using "http://localhost:$port" url_roots, and then run into the problem on hosts with IPv6 that localhost resolves to ::1 rather than 127.0.0.1 and so connections to the test service will fail.

1) t/dead-connection.t - could be fixed by either using IO::Socket::IP rather than IO::Socket::INET, or by explicitly creating the request using 127.0.0.1:

my $req = HTTP::Request->new( GET => "http://127.0.0.1:$port/" );

I don't know which is the more portable solution.

2) In both t/bad-connections.t and 3) t/peer-addr.t

TestServer->new() results in an IPv4 socket being created. $s->started_ok() returns "http://localhost:$port"

I've submitted a bug for Test::HTTP::Server::Simple (https://rt.cpan.org/Public/Bug/Display.html?id=124363) with a suggestion that would address these two cases, as well as possibly any other modules that follow the Test::HTTP::Server::Simple synopsis.

Otherwise, these two cases could be addressed by the test files using "http://127.0.0.1:$port"rather than the string returned by started_ok().

With both suggestions, 127.0.0.1 might not be a fully portable assumption, but the number of people that might catch out is probably a lot smaller than the number of people having IPv6 capable hosts.

Many Thanks, Rich