Package org.apache.http
Class HttpHost
java.lang.Object
org.apache.http.HttpHost
- All Implemented Interfaces:
Serializable
,Cloneable
@Contract(threading=IMMUTABLE)
public final class HttpHost
extends Object
implements Cloneable, Serializable
Holds all of the variables needed to describe an HTTP connection to a host.
This includes remote host name, port and scheme.
- Since:
- 4.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InetAddress
static final String
The default scheme is "http".protected final String
The host to use.protected final String
The lowercase host, forequals(java.lang.Object)
andhashCode()
.protected final int
The port to use, defaults to -1 if not set.protected final String
The scheme (lowercased)private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionCreatesHttpHost
instance with the default scheme and port and the given hostname.CreatesHttpHost
instance with the default scheme and the given hostname and port.CreatesHttpHost
instance with the given scheme, hostname and port.HttpHost
(InetAddress address) CreatesHttpHost
instance with the default scheme and port and the given inet address.HttpHost
(InetAddress address, int port) CreatesHttpHost
instance with the default scheme and the given inet address and port.HttpHost
(InetAddress address, int port, String scheme) CreatesHttpHost
instance with the given scheme, inet address and port.HttpHost
(InetAddress address, String hostname, int port, String scheme) Creates a newHttpHost
, specifying all values.Copy constructor forHttpHost
. -
Method Summary
Modifier and TypeMethodDescriptionclone()
static HttpHost
CreatesHttpHost
instance from string.boolean
Returns the inet address if explicitly set by a constructor,null
otherwise.Returns the host name.int
getPort()
Returns the port.Returns the scheme name.int
hashCode()
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_NAME
The default scheme is "http".- See Also:
-
hostname
The host to use. -
lcHostname
The lowercase host, forequals(java.lang.Object)
andhashCode()
. -
port
protected final int portThe port to use, defaults to -1 if not set. -
schemeName
The scheme (lowercased) -
address
-
-
Constructor Details
-
HttpHost
CreatesHttpHost
instance with the given scheme, hostname and port.- Parameters:
hostname
- the hostname (IP or DNS name)port
- the port number.-1
indicates the scheme default port.scheme
- the name of the scheme.null
indicates thedefault scheme
-
HttpHost
CreatesHttpHost
instance with the default scheme and the given hostname and port.- Parameters:
hostname
- the hostname (IP or DNS name)port
- the port number.-1
indicates the scheme default port.
-
HttpHost
CreatesHttpHost
instance with the default scheme and port and the given hostname.- Parameters:
hostname
- the hostname (IP or DNS name)
-
HttpHost
CreatesHttpHost
instance with the given scheme, inet address and port.- Parameters:
address
- the inet address.port
- the port number.-1
indicates the scheme default port.scheme
- the name of the scheme.null
indicates thedefault scheme
- Since:
- 4.3
-
HttpHost
Creates a newHttpHost
, specifying all values. Constructor for HttpHost.- Parameters:
address
- the inet address.hostname
- the hostname (IP or DNS name)port
- the port number.-1
indicates the scheme default port.scheme
- the name of the scheme.null
indicates thedefault scheme
- Since:
- 4.4
-
HttpHost
CreatesHttpHost
instance with the default scheme and the given inet address and port.- Parameters:
address
- the inet address.port
- the port number.-1
indicates the scheme default port.- Since:
- 4.3
-
HttpHost
CreatesHttpHost
instance with the default scheme and port and the given inet address.- Parameters:
address
- the inet address.- Since:
- 4.3
-
HttpHost
Copy constructor forHttpHost
.- Parameters:
httphost
- the HTTP host to copy details from
-
-
Method Details
-
create
CreatesHttpHost
instance from string. Text may not contain any blanks.- Since:
- 4.4
-
getHostName
Returns the host name.- Returns:
- the host name (IP or DNS name)
-
getPort
public int getPort()Returns the port.- Returns:
- the host port, or
-1
if not set
-
getSchemeName
Returns the scheme name.- Returns:
- the scheme name
-
getAddress
Returns the inet address if explicitly set by a constructor,null
otherwise.- 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() -
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-