>>>>> On Wed, 30 Jul 2014 13:20:40 +1000, Greg Wilkins <gregw_at_intalio.com> said:
GW> On 25 July 2014 11:13, Edward Burns <edward.burns_at_oracle.com> wrote:
>> >>>>> On Mon, 30 Jun 2014 16:43:16 +0200, Greg Wilkins <gregw_at_intalio.com>
>> said:
>>
GW> I think we need to clarify the handling of raw IPv6 addresses when
>> they are
GW> sent as part of the URI authority and/or Host header.
>>
GW> Currently the javadoc for getServerName says:
>>
>> Agreed, I've filed: https://java.net/jira/browse/SERVLET_SPEC-97.
>>
>>
GW> Opps I had already opened
https://java.net/jira/browse/SERVLET_SPEC-93
>> Is it possible to unambiguously determine if the hostname is an IPv6
>> hostname or an IPv4 hostname?
>>
GW> I think so, as the BNF in RFC3986 says:
GW> authority = [ userinfo "@" ] host [ ":" port ]
GW> host = IP-literal / IPv4address / reg-name
GW> IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
GW> IP-literal = "[" ( IPv6address / IPvFuture ) "]"
GW> IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
GW> reg-name = *( unreserved / pct-encoded / sub-delims )
GW> unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
GW> pct-encoded = "%" HEXDIG HEXDIG
GW> sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
GW> So since [ is not in reg-name (unreservced, pct-encoded or sub-delims) and
GW> it not in IPv4address, then we can always tell an IPv6 literal address from
GW> a hostname.
To be clear, the presence of [ in the host name unambiguously indicates
that the hostname should be treated as an IPv6 host name, otherwise, we
must treat it as an IPv4 hostname. Right?
Ed
--
| edward.burns_at_oracle.com | office: +1 407 458 0017
| 34 work days til JavaOne 2014