Class HostConfiguration
java.lang.Object
org.apache.commons.httpclient.HostConfiguration
- All Implemented Interfaces:
Cloneable
Holds all of the variables needed to describe an HTTP connection to a host. This includes
remote host, port and protocol, proxy host and port, local address, and virtual host.
- Since:
- 2.0
- Author:
- Michael Becke, Mike Bowler, Oleg Kalnichevski, Laura Werner
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HostConfigurationA value to represent any host configuration, instead of using something likenull. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for HostConfiguration.HostConfiguration(HostConfiguration hostConfiguration) Copy constructor for HostConfiguration -
Method Summary
Modifier and TypeMethodDescriptionclone()booleangetHost()Returns the host.Return the host url.Return the local address to be used when creating connections.ReturnsHTTP protocol parametersassociated with this host.intgetPort()Returns the port.Returns the protocol.Returns the proxyHost.intReturns the proxyPort.Deprecated.use HostParamsinthashCode()booleanhostEquals(HttpConnection connection) Tests if the host configuration equals the configuration set on the connection.booleanDeprecated.no longer usedbooleanDeprecated.no longer usedbooleanproxyEquals(HttpConnection connection) Tests if the proxy configuration equals the configuration set on the connection.voidSet the given host.voidSets the given host and port.voidSets the given host, port and protocolvoidSets the given host, port and protocol.voidDeprecated.#setHost(String, int, Protocol)voidSets the given hostvoidSets the protocol, host and port from the given URI.voidsetLocalAddress(InetAddress localAddress) Set the local address to be used when creating connections.voidsetParams(HostParams params) AssignsHTTP protocol parametersspecific to this host.voidSet the proxy settings.voidsetProxyHost(ProxyHost proxyHost) Sets the given proxy hosttoString()
-
Field Details
-
ANY_HOST_CONFIGURATION
A value to represent any host configuration, instead of using something likenull. This value should be treated as immutable and only used in lookups and other such places to represent "any" host config.
-
-
Constructor Details
-
HostConfiguration
public HostConfiguration()Constructor for HostConfiguration. -
HostConfiguration
Copy constructor for HostConfiguration- Parameters:
hostConfiguration- the hostConfiguration to copy
-
-
Method Details
-
clone
-
toString
-
hostEquals
Tests if the host configuration equals the configuration set on the connection. True only if the host, port, protocol, local address and virtual address are equal. If no host configuration has been set false will be returned.- Parameters:
connection- the connection to test against- Returns:
trueif the connection's host information equals that of this configuration- See Also:
-
proxyEquals
Tests if the proxy configuration equals the configuration set on the connection. True only if the proxyHost and proxyPort are equal.- Parameters:
connection- the connection to test against- Returns:
trueif the connection's proxy information equals that of this configuration- See Also:
-
isHostSet
public boolean isHostSet()Deprecated.no longer usedReturns true if the host is set.- Returns:
trueif the host is set.
-
setHost
-
setHost
-
setHost
Deprecated.#setHost(String, int, Protocol)Sets the given host, virtual host, port and protocol.- Parameters:
host- the host(IP or DNS name)virtualHost- the virtual host name ornullport- the host port or -1 to use protocol defaultprotocol- the protocol
-
setHost
-
setHost
Sets the given host and port. Uses the default protocol "http".- Parameters:
host- the host(IP or DNS name)port- The port
-
setHost
Set the given host. Uses the default protocol("http") and its port.- Parameters:
host- The host(IP or DNS name).
-
setHost
Sets the protocol, host and port from the given URI.- Parameters:
uri- the URI.
-
getHostURL
-
getHost
Returns the host.- Returns:
- the host(IP or DNS name), or
nullif not set - See Also:
-
getVirtualHost
Deprecated.use HostParamsReturns the virtual host.- Returns:
- the virtual host name, or
nullif not set
-
getPort
public int getPort()Returns the port.- Returns:
- the host port, or
-1if not set - See Also:
-
getProtocol
-
isProxySet
public boolean isProxySet()Deprecated.no longer usedTests if the proxy host/port have been set.- Returns:
trueif a proxy server has been set.- See Also:
-
setProxyHost
Sets the given proxy host- Parameters:
proxyHost- the proxy host
-
setProxy
Set the proxy settings.- Parameters:
proxyHost- The proxy hostproxyPort- The proxy port
-
getProxyHost
Returns the proxyHost.- Returns:
- the proxy host, or
nullif not set - See Also:
-
getProxyPort
public int getProxyPort()Returns the proxyPort.- Returns:
- the proxy port, or
-1if not set - See Also:
-
setLocalAddress
Set the local address to be used when creating connections. If this is unset, the default address will be used. This is useful for specifying the interface to use on multi-homed or clustered systems.- Parameters:
localAddress- the local address to use
-
getLocalAddress
Return the local address to be used when creating connections. If this is unset, the default address should be used.- Returns:
- the local address to be used when creating Sockets, or
null
-
getParams
ReturnsHTTP protocol parametersassociated with this host.- Returns:
- HTTP parameters.
- Since:
- 3.0
-
setParams
AssignsHTTP protocol parametersspecific to this host.- Since:
- 3.0
- See Also:
-
equals
-
hashCode
-