java.lang.Object
org.eclipse.jetty.util.HostPort
Parse an authority string (in the form host:port) into
host and port, handling IPv4 and IPv6 host formats
as defined in https://www.ietf.org/rfc/rfc2732.txt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetHost()Get the host.intgetPort()Get the port.intgetPort(int defaultPort) Get the port or the given default port.booleanhasHost()booleanhasPort()protected booleanisValidHostName(String name) protected booleanstatic StringnormalizeHost(String host) Normalizes IPv6 address as per https://tools.ietf.org/html/rfc2732 and https://tools.ietf.org/html/rfc6874, surrounding with square brackets if they are absent.static intParse a string representing a port validating it is a valid port value.toString()
-
Constructor Details
-
HostPort
-
HostPort
- Throws:
IllegalArgumentException
-
-
Method Details
-
isValidIpAddress
-
isValidHostName
-
getHost
Get the host.- Returns:
- the host
-
getPort
Get the port.- Returns:
- the port
-
getPort
public int getPort(int defaultPort) Get the port or the given default port.- Parameters:
defaultPort- , the default port to return if a port is not specified- Returns:
- the port
-
hasHost
public boolean hasHost() -
hasPort
public boolean hasPort() -
toString
-
normalizeHost
Normalizes IPv6 address as per https://tools.ietf.org/html/rfc2732 and https://tools.ietf.org/html/rfc6874, surrounding with square brackets if they are absent.- Parameters:
host- a host name, IPv4 address, IPv6 address or IPv6 literal- Returns:
- a host name or an IPv4 address or an IPv6 literal (not an IPv6 address)
-
parsePort
Parse a string representing a port validating it is a valid port value.- Parameters:
rawPort- the port string.- Returns:
- the integer value for the port.
- Throws:
IllegalArgumentException- if the port is invalid
-