irb(main):002:0> URI.parse("http://[::1]").host
=> "[::1]"
irb(main):003:0> Socket.getaddrinfo("[::1]", nil)
SocketError: getaddrinfo: No address associated with nodename
from (irb):3:in `getaddrinfo'
from (irb):3
I think that URI should remove the [] from the host part when it parses,
and add it back in when it builds.
I see this problem propogates itself up through net/http, open-uri,
etc... None of these APIs seem to accept IPv6 URIs (at least not ::1,
loopback, the only one I can connect to).
It also won't encode IPv6 addresses:
URI::HTTP.build(:scheme => 'http', :host => '::1').to_s
URI::InvalidComponentError: bad component(expected host component): ::1
from /usr/local/lib/ruby/1.8/uri/generic.rb:380:in `check_host'
...
This works:
URI::HTTP.build(:scheme => 'http', :host => '[::1]').to_s)
=> "http://[::1]"
But it's URI's job to know the IPv6 URI syntax, not mine!
|