Package org.apache.hc.core5.http
Class HttpHost
java.lang.Object
org.apache.hc.core5.http.HttpHost
- All Implemented Interfaces:
Serializable,NamedEndpoint
@Contract(threading=IMMUTABLE)
public final class HttpHost
extends Object
implements NamedEndpoint, Serializable
Component that holds all details needed to describe an HTTP connection
to a host. This includes remote host name, port and protocol scheme.
- Since:
- 4.0, 5.0 For constructors that take a scheme as an argument, that argument is now the first one.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InetAddressstatic final URISchemeThe default scheme is "http".private final Hostprivate final Stringprivate static final long -
Constructor Summary
ConstructorsConstructorDescriptionCreatesHttpHostinstance with the default scheme and port and the given hostname.CreatesHttpHostinstance with the default scheme and the given hostname and port.CreatesHttpHostinstance with the given hostname and scheme and the default port for that scheme.CreatesHttpHostinstance with the given scheme, hostname and port.HttpHost(String scheme, InetAddress address, int port) CreatesHttpHostinstance with the given scheme, inet address and port.HttpHost(String scheme, InetAddress address, String hostname, int port) Creates a newHttpHost, specifying all values.HttpHost(String scheme, NamedEndpoint namedEndpoint) HttpHost(InetAddress address) CreatesHttpHostinstance with the default scheme and port and the given inet address.HttpHost(InetAddress address, int port) CreatesHttpHostinstance with the default scheme and the given inet address and port.HttpHost(URIAuthority authority) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpHostCreatesHttpHostinstance from a string.static HttpHostCreates anHttpHostinstance from the scheme, host, and port from the given URI.booleanReturns the inet address if explicitly set by a constructor,nullotherwise.Returns the host name.intgetPort()Returns the port.Returns the scheme name.inthashCode()Obtains the host string, without scheme prefix.toString()toURI()Return the host URI, as a string.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
DEFAULT_SCHEME
The default scheme is "http". -
schemeName
-
host
-
address
-
-
Constructor Details
-
HttpHost
Creates a newHttpHost, specifying all values. Constructor for HttpHost.- Parameters:
scheme- the name of the scheme.nullindicates thedefault schemeaddress- the inet address. Can benullhostname- the hostname (IP or DNS name)port- the port number.-1indicates the scheme default port.- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.- Since:
- 5.0
-
HttpHost
CreatesHttpHostinstance with the given scheme, hostname and port.- Parameters:
scheme- the name of the scheme.nullindicates thedefault schemehostname- the hostname (IP or DNS name)port- the port number.-1indicates the scheme default port.- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.
-
HttpHost
CreatesHttpHostinstance with the default scheme and the given hostname and port.- Parameters:
hostname- the hostname (IP or DNS name)port- the port number.-1indicates the scheme default port.- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.
-
HttpHost
CreatesHttpHostinstance with the given hostname and scheme and the default port for that scheme.- Parameters:
scheme- the name of the scheme.nullindicates thedefault schemehostname- the hostname (IP or DNS name)- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.
-
HttpHost
CreatesHttpHostinstance with the default scheme and port and the given hostname.- Parameters:
hostname- the hostname (IP or DNS name)- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.
-
HttpHost
CreatesHttpHostinstance with the given scheme, inet address and port.- Parameters:
scheme- the name of the scheme.nullindicates thedefault schemeaddress- the inet address.port- the port number.-1indicates the scheme default port.- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.- Since:
- 5.0
-
HttpHost
CreatesHttpHostinstance with the default scheme and the given inet address and port.- Parameters:
address- the inet address.port- the port number.-1indicates the scheme default port.- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.- Since:
- 4.3
-
HttpHost
CreatesHttpHostinstance with the default scheme and port and the given inet address.- Parameters:
address- the inet address.- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.- Since:
- 4.3
-
HttpHost
- Throws:
IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.- Since:
- 5.0
-
HttpHost
Deprecated.- Since:
- 5.0
-
-
Method Details
-
create
CreatesHttpHostinstance from a string. Text may not contain any blanks.- Throws:
URISyntaxException- Since:
- 4.4
-
create
Creates anHttpHostinstance from the scheme, host, and port from the given URI. Other URI elements are ignored.- Parameters:
uri- scheme, host, and port.- Returns:
- a new HttpHost
- Since:
- 5.0
-
getHostName
Returns the host name.- Specified by:
getHostNamein interfaceNamedEndpoint- Returns:
- the host name (IP or DNS name)
-
getPort
public int getPort()Returns the port.- Specified by:
getPortin interfaceNamedEndpoint- Returns:
- the host port, or
-1if not set
-
getSchemeName
Returns the scheme name.- Returns:
- the scheme name
-
getAddress
Returns the inet address if explicitly set by a constructor,nullotherwise.- Returns:
- the inet address
- Since:
- 4.3
-
toURI
Return the host URI, as a string.- Returns:
- the host URI
-
toHostString
Obtains the host string, without scheme prefix.- Returns:
- the host string, for example
localhost:8080
-
toString
-
equals
-
hashCode
public int hashCode()
-
HttpHost(String, NamedEndpoint)