Top Description Fields Constructors Methods
org.apache.http.conn.routing

public final Class HttpRoute

extends Object
implements RouteInfo, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.apache.http.conn.routing.RouteInfo
Annotations
@Contract
threading:IMMUTABLE
Imports
java.net.InetAddress, .InetSocketAddress, java.util.ArrayList, .Arrays, .Collections, .List, org.apache.http.HttpHost, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.util.Args, .LangUtils

The route for a request.
Since
4.0

Field Summary

Modifier and TypeField and Description
private final RouteInfo.LayerType
layered

Whether the route is layered.

private final InetAddress
localAddress

The local address to connect from.

private final List<HttpHost>
proxyChain

The proxy servers, if any.

private final boolean
secure

Whether the route is (supposed to be) secure.

private final HttpHost
targetHost

The target host to connect to.

private final RouteInfo.TunnelType
tunnelled

Whether the the route is tunnelled through the proxy.

Constructor Summary

AccessConstructor and Description
private
HttpRoute(final HttpHost target, final InetAddress local, final List<HttpHost> proxies, final boolean secure, final RouteInfo.TunnelType tunnelled, final RouteInfo.LayerType layered)

public
HttpRoute(final HttpHost
the host to which to route
target
,
final InetAddress
the local address to route from, or null for the default
local
,
final HttpHost[]
the proxy chain to use, or null for a direct route
proxies
,
final boolean
true if the route is (to be) secure, false otherwise
secure
,
final RouteInfo.TunnelType
the tunnel type of this route
tunnelled
,
final RouteInfo.LayerType
the layering type of this route
layered
)

Creates a new route with all attributes specified explicitly.

public
HttpRoute(final HttpHost
the host to which to route
target
,
final InetAddress
the local address to route from, or null for the default
local
,
final HttpHost
the proxy to use, or null for a direct route
proxy
,
final boolean
true if the route is (to be) secure, false otherwise
secure
,
final RouteInfo.TunnelType
true if the route is (to be) tunnelled via the proxy, false otherwise
tunnelled
,
final RouteInfo.LayerType
true if the route includes a layered protocol, false otherwise
layered
)

Creates a new route with at most one proxy.

public
HttpRoute(final HttpHost
the host to which to route
target
,
final InetAddress
the local address to route from, or null for the default
local
,
final boolean
true if the route is (to be) secure, false otherwise
secure
)

Creates a new direct route.

public
HttpRoute(final HttpHost
the host to which to route
target
)

Creates a new direct insecure route.

public
HttpRoute(final HttpHost
the host to which to route
target
,
final InetAddress
the local address to route from, or null for the default
local
,
final HttpHost
the proxy to use
proxy
,
final boolean
true if the route is (to be) secure, false otherwise
secure
)

Creates a new route through a proxy.

public
HttpRoute(final HttpHost
the host to which to route
target
,
final HttpHost
the proxy to use
proxy
)

Creates a new plain route through a proxy.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean

Returns:

true if the argument is the same route, false
equals
(final Object
the object to compare with
obj
)

Overrides java.lang.Object.equals.

Compares this route to another.
private static int
getDefaultPort(final String schemeName)

public int
getHopCount()

Implements org.apache.http.conn.routing.RouteInfo.getHopCount.

Obtains the number of hops in this route.
public HttpHost
getHopTarget(final int
index of the hop for which to get the target, 0 for first
hop
)

Implements org.apache.http.conn.routing.RouteInfo.getHopTarget.

Obtains the target of a hop in this route.
public RouteInfo.LayerType
getLayerType()

Implements org.apache.http.conn.routing.RouteInfo.getLayerType.

Obtains the layering type of this route.
public InetAddress
getLocalAddress()

Implements org.apache.http.conn.routing.RouteInfo.getLocalAddress.

Obtains the local address to connect from.
public InetSocketAddress
public HttpHost
getProxyHost()

Implements org.apache.http.conn.routing.RouteInfo.getProxyHost.

Obtains the first proxy host.
public HttpHost
public RouteInfo.TunnelType
getTunnelType()

Implements org.apache.http.conn.routing.RouteInfo.getTunnelType.

Obtains the tunnel type of this route.
public int

Returns:

the hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Generates a hash code for this route.
public boolean
isLayered()

Implements org.apache.http.conn.routing.RouteInfo.isLayered.

Checks whether this route includes a layered protocol.
public boolean
isSecure()

Implements org.apache.http.conn.routing.RouteInfo.isSecure.

Checks whether this route is secure.
public boolean
isTunnelled()

Implements org.apache.http.conn.routing.RouteInfo.isTunnelled.

Checks whether this route is tunnelled through a proxy.
private static HttpHost
normalize(final HttpHost target)

public String

Returns:

a human-readable representation of this route
toString
()

Overrides java.lang.Object.toString.

Obtains a description of this route.
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

layeredback to summary
private final RouteInfo.LayerType layered

Whether the route is layered.

localAddressback to summary
private final InetAddress localAddress

The local address to connect from. null indicates that the default should be used.

proxyChainback to summary
private final List<HttpHost> proxyChain

The proxy servers, if any. Never null.

secureback to summary
private final boolean secure

Whether the route is (supposed to be) secure.

targetHostback to summary
private final HttpHost targetHost

The target host to connect to.

tunnelledback to summary
private final RouteInfo.TunnelType tunnelled

Whether the the route is tunnelled through the proxy.

Constructor Detail

HttpRouteback to summary
private HttpRoute(final HttpHost target, final InetAddress local, final List<HttpHost> proxies, final boolean secure, final RouteInfo.TunnelType tunnelled, final RouteInfo.LayerType layered)
HttpRouteback to summary
public HttpRoute(final HttpHost target, final InetAddress local, final HttpHost[] proxies, final boolean secure, final RouteInfo.TunnelType tunnelled, final RouteInfo.LayerType layered)

Creates a new route with all attributes specified explicitly.

Parameters
target:HttpHost

the host to which to route

local:InetAddress

the local address to route from, or null for the default

proxies:HttpHost[]

the proxy chain to use, or null for a direct route

secure:boolean

true if the route is (to be) secure, false otherwise

tunnelled:RouteInfo.TunnelType

the tunnel type of this route

layered:RouteInfo.LayerType

the layering type of this route

HttpRouteback to summary
public HttpRoute(final HttpHost target, final InetAddress local, final HttpHost proxy, final boolean secure, final RouteInfo.TunnelType tunnelled, final RouteInfo.LayerType layered)

Creates a new route with at most one proxy.

Parameters
target:HttpHost

the host to which to route

local:InetAddress

the local address to route from, or null for the default

proxy:HttpHost

the proxy to use, or null for a direct route

secure:boolean

true if the route is (to be) secure, false otherwise

tunnelled:RouteInfo.TunnelType

true if the route is (to be) tunnelled via the proxy, false otherwise

layered:RouteInfo.LayerType

true if the route includes a layered protocol, false otherwise

HttpRouteback to summary
public HttpRoute(final HttpHost target, final InetAddress local, final boolean secure)

Creates a new direct route. That is a route without a proxy.

Parameters
target:HttpHost

the host to which to route

local:InetAddress

the local address to route from, or null for the default

secure:boolean

true if the route is (to be) secure, false otherwise

HttpRouteback to summary
public HttpRoute(final HttpHost target)

Creates a new direct insecure route.

Parameters
target:HttpHost

the host to which to route

HttpRouteback to summary
public HttpRoute(final HttpHost target, final InetAddress local, final HttpHost proxy, final boolean secure)

Creates a new route through a proxy. When using this constructor, the proxy MUST be given. For convenience, it is assumed that a secure connection will be layered over a tunnel through the proxy.

Parameters
target:HttpHost

the host to which to route

local:InetAddress

the local address to route from, or null for the default

proxy:HttpHost

the proxy to use

secure:boolean

true if the route is (to be) secure, false otherwise

HttpRouteback to summary
public HttpRoute(final HttpHost target, final HttpHost proxy)

Creates a new plain route through a proxy.

Parameters
target:HttpHost

the host to which to route

proxy:HttpHost

the proxy to use

Since
4.3

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Compares this route to another.

Parameters
obj:Object

the object to compare with

Returns:boolean

true if the argument is the same route, false

Annotations
@Override
getDefaultPortback to summary
private static int getDefaultPort(final String schemeName)
getHopCountback to summary
public int getHopCount()

Implements org.apache.http.conn.routing.RouteInfo.getHopCount.

Doc from org.apache.http.conn.routing.RouteInfo.getHopCount.

Obtains the number of hops in this route. A direct route has one hop. A route through a proxy has two hops. A route through a chain of n proxies has n+1 hops.

Returns:int

the number of hops in this route

Annotations
@Override
getHopTargetback to summary
public HttpHost getHopTarget(final int hop)

Implements org.apache.http.conn.routing.RouteInfo.getHopTarget.

Doc from org.apache.http.conn.routing.RouteInfo.getHopTarget.

Obtains the target of a hop in this route. The target of the last hop is the target host, the target of previous hops is the respective proxy in the chain. For a route through exactly one proxy, target of hop 0 is the proxy and target of hop 1 is the target host.

Parameters
hop:int

index of the hop for which to get the target, 0 for first

Returns:HttpHost

the target of the given hop

Annotations
@Override
getLayerTypeback to summary
public RouteInfo.LayerType getLayerType()

Implements org.apache.http.conn.routing.RouteInfo.getLayerType.

Doc from org.apache.http.conn.routing.RouteInfo.getLayerType.

Obtains the layering type of this route. In the presence of proxies, only layering over an end-to-end tunnel is considered.

Returns:RouteInfo.LayerType

the layering type

Annotations
@Override
getLocalAddressback to summary
public InetAddress getLocalAddress()

Implements org.apache.http.conn.routing.RouteInfo.getLocalAddress.

Doc from org.apache.http.conn.routing.RouteInfo.getLocalAddress.

Obtains the local address to connect from.

Returns:InetAddress

the local address, or null

Annotations
@Override
getLocalSocketAddressback to summary
public InetSocketAddress getLocalSocketAddress()
getProxyHostback to summary
public HttpHost getProxyHost()

Implements org.apache.http.conn.routing.RouteInfo.getProxyHost.

Doc from org.apache.http.conn.routing.RouteInfo.getProxyHost.

Obtains the first proxy host.

Returns:HttpHost

the first proxy in the proxy chain, or null if this route is direct

Annotations
@Override
getTargetHostback to summary
public HttpHost getTargetHost()

Implements org.apache.http.conn.routing.RouteInfo.getTargetHost.

Doc from org.apache.http.conn.routing.RouteInfo.getTargetHost.

Obtains the target host.

Returns:HttpHost

the target host

Annotations
@Override
getTunnelTypeback to summary
public RouteInfo.TunnelType getTunnelType()

Implements org.apache.http.conn.routing.RouteInfo.getTunnelType.

Doc from org.apache.http.conn.routing.RouteInfo.getTunnelType.

Obtains the tunnel type of this route. If there is a proxy chain, only end-to-end tunnels are considered.

Returns:RouteInfo.TunnelType

the tunnelling type

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Generates a hash code for this route.

Returns:int

the hash code

Annotations
@Override
isLayeredback to summary
public boolean isLayered()

Implements org.apache.http.conn.routing.RouteInfo.isLayered.

Doc from org.apache.http.conn.routing.RouteInfo.isLayered.

Checks whether this route includes a layered protocol. In the presence of proxies, only layering over an end-to-end tunnel is considered.

Returns:boolean

true if layered, false otherwise

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements org.apache.http.conn.routing.RouteInfo.isSecure.

Doc from org.apache.http.conn.routing.RouteInfo.isSecure.

Checks whether this route is secure.

Returns:boolean

true if secure, false otherwise

Annotations
@Override
isTunnelledback to summary
public boolean isTunnelled()

Implements org.apache.http.conn.routing.RouteInfo.isTunnelled.

Doc from org.apache.http.conn.routing.RouteInfo.isTunnelled.

Checks whether this route is tunnelled through a proxy. If there is a proxy chain, only end-to-end tunnels are considered.

Returns:boolean

true if tunnelled end-to-end through at least one proxy, false otherwise

Annotations
@Override
normalizeback to summary
private static HttpHost normalize(final HttpHost target)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Obtains a description of this route.

Returns:String

a human-readable representation of this route

Annotations
@Override