http-useragent
http-useragent copied to clipboard
t/08-ua.t fails
$ perl6-m -Ilib t/08-ua.t
1..9
ok 1 - new 1/3
ok 2 - new 2/3
ok 3 - new 3/3
Failed to connect: host is unreachable
in method request at /home/tokuhirom/dev/http-useragent/lib/HTTP/UserAgent.pm6:136
in method get at /home/tokuhirom/dev/http-useragent/lib/HTTP/UserAgent.pm6:95
in method get at /home/tokuhirom/dev/http-useragent/lib/HTTP/UserAgent.pm6:98
in block <unit> at t/08-ua.t:20
# Looks like you planned 9 tests, but ran 3
ua.offensivecoder.com has IPv6 and IPv4 address. But IPv6 IP is not reachable.
$ curl -vvv http://ua.offensivecoder.com/
* About to connect() to ua.offensivecoder.com port 80 (#0)
* Trying 2001:41d0:51:1::2398...
* No route to host
* Trying 37.59.117.163...
* Connected to ua.offensivecoder.com (37.59.117.163) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: ua.offensivecoder.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 16 Oct 2015 01:02:26 GMT
< Server: Microsoft-IIS/9.0
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1;mode=block
< Vary: Accept-Encoding
< Content-Length: 12
< Content-Type: text/plain
<
curl/7.29.0
* Connection #0 to host ua.offensivecoder.com left intact
Unfortunately I'm not able to test this properly because I don't have V6 here.
I'd assumed, because the default for "family" in the arguments to IO::Socket::INET.new is PIO::SOCK_INET and not PIO::SOCK_INET6 that it wouldn't attempt the v6 connection (or even attempt to resolve the AAAA record,) but this appears not to be the case.
The IO::Socket::INET is really only a very thin layer over the NQP sockets stuff and that itself is an abstraction (for rakudo/MoarVM at least,) of the libuv sockets part. The solution probably lies in one of those parts as it doesn't appear to be possible to fix the behaviour in Perl 6 space.
I'll try and track down someone who has an IPV6 service and understands the socket implementation to see if they can shed some light on this.
I'm minded to file a bug against rakudo for this, I don't think it should be preferring V6 without being told to do so, and I think that if it is going to do some kind of magic then it should try both and only fail if it can't connect either.
The ticket is https://rt.perl.org/Ticket/Display.html?id=126401
The workaround is to separately resolve the IP address of a domain name using e.g. Net::DNS and only use either the IPV4 or IPV6 address as appropriate. This would frankly be a pain in the arse.
This is fixed temporarily at the moment in https://github.com/sergot/http-useragent/commit/197a94edd3f9c7fec9b714b999c10a971fe77026.
Well it stops the test from failing :) :+1:
@jonathanstowe So what's the resolution on this one? :+1: