benoitc / hackney

simple HTTP client in Erlang
Other
1.34k stars 427 forks source link

Connect to IPv6 addresses #554

Closed nroi closed 4 months ago

nroi commented 5 years ago

Hackney supports connecting to a client by providing the IPv4 instead of its hostname:

hackney:request(get, '78.46.175.29')

It also supports connecting to IPv6 hosts:

hackney:request(get, 'ipv6.xnet.space')

But it fails when attempting to connect to an IPv6 host by providing is IPv6 address:

hackney:request(get, '2a01:4f8:c0c:1de8::2')

I've tried different IPv6 notations, but hackney seems to assume that the given URL is either a hostname, or an IPv4 address.

If it were possible to connect to IPv6 addresses, this would also provide the possibility to implement something like "happy eyeballs" / RFC 8305 on top of hackney. I'm currently using hackney with a very crude workaround to decide whether to use IPv4 or IPv6 to connect to a host.

benoitc commented 5 years ago

normally the url should be given as hackney:request(get, "http://[2a01:4f8:c0c:1de8::2]"). But then there is an issue with IDNA that should be fixed. I will take care of it later today :)

As eyeball, there is #206 opened long time ago . I aim to implement it but any PR is welcome :)

benoitc commented 5 years ago

idna error has been fixed in latest master with 42875a9b9149be828e698736579eab65607b113f.

benoitc commented 4 months ago

closing as done.