Class HostPort


  • public class HostPort
    extends Object
    Parse an authority string into Host and Port

    Parse a string in the form "host:port", handling IPv4 an IPv6 hosts

    The System property "org.eclipse.jetty.util.HostPort.STRIP_IPV6" can be set to a boolean value to control of the square brackets are stripped off IPv6 addresses (default false).

    • Method Detail

      • getHost

        public String getHost()
        Get the host.
        Returns:
        the host
      • getPort

        public int getPort()
        Get the port.
        Returns:
        the port
      • getPort

        public int getPort​(int defaultPort)
        Get the port.
        Parameters:
        defaultPort - , the default port to return if a port is not specified
        Returns:
        the port
      • normalizeHost

        public static String normalizeHost​(String host)
        Normalize IPv6 address as per https://www.ietf.org/rfc/rfc2732.txt
        Parameters:
        host - A host name
        Returns:
        Host name surrounded by '[' and ']' as needed.