users@servlet-spec.java.net

[servlet-spec users] [jsr340-experts] IPv6 clarification

From: Greg Wilkins <gregw_at_intalio.com>
Date: Mon, 30 Jun 2014 16:43:16 +0200

I think we need to clarify the handling of raw IPv6 addresses when they are
sent as part of the URI authority and/or Host header.

Currently the javadoc for getServerName says:

    /**
     * Returns the host name of the server to which the request was sent.
     * It is the value of the part before ":" in the <code>Host</code>
     * header value, if any, or the resolved server name, or the server IP
     * address.
     */

That this is ambiguous, since for a Host header like [::1]:8080, both
"[::1]" and "::1" satisfy an or clause in the javadoc (the part before the
":" and the server IP address).

I'm not 100% sure what we should return, since including the [] makes
constructing URIs easier (but we have getRequetURI for that), but the []
are not part of the IP address and only part of the encoding of an IPv6
address in a URI. Since the return is a hostname, then it should be able
to be passed to methods that resolve host names, and they have no
obligation to string []. So I probably lean towards stripping off the [].

But whichever way we go, we should update the javadoc to make it clear what
it is.

cheers


-- 
Greg Wilkins <gregw_at_intalio.com>
http://eclipse.org/jetty HTTP, SPDY, Websocket server and client that scales
http://www.webtide.com  advice and support for jetty and cometd.