public final class

HttpRoute

extends Object
implements Cloneable RouteInfo
java.lang.Object
   ↳ org.apache.http.conn.routing.HttpRoute

Class Overview

The route for a request. Instances of this class are unmodifiable and therefore suitable for use as lookup keys.

Summary

Public Constructors
HttpRoute(HttpHost target, InetAddress local, HttpHost[] proxies, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)
Creates a new route with all attributes specified explicitly.
HttpRoute(HttpHost target, InetAddress local, HttpHost proxy, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)
Creates a new route with at most one proxy.
HttpRoute(HttpHost target, InetAddress local, boolean secure)
Creates a new direct route.
HttpRoute(HttpHost target)
Creates a new direct insecure route.
HttpRoute(HttpHost target, InetAddress local, HttpHost proxy, boolean secure)
Creates a new route through a proxy.
Public Methods
Object clone()
Creates and returns a copy of this Object.
final boolean equals(Object o)
Compares this route to another.
final int getHopCount()
Obtains the number of hops in this route.
final HttpHost getHopTarget(int hop)
Obtains the target of a hop in this route.
final RouteInfo.LayerType getLayerType()
Obtains the layering type of this route.
final InetAddress getLocalAddress()
Obtains the local address to connect from.
final HttpHost getProxyHost()
Obtains the first proxy host.
final HttpHost getTargetHost()
Obtains the target host.
final RouteInfo.TunnelType getTunnelType()
Obtains the tunnel type of this route.
final int hashCode()
Generates a hash code for this route.
final boolean isLayered()
Checks whether this route includes a layered protocol.
final boolean isSecure()
Checks whether this route is secure.
final boolean isTunnelled()
Checks whether this route is tunnelled through a proxy.
final String toString()
Obtains a description of this route.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.conn.routing.RouteInfo

Public Constructors

public HttpRoute (HttpHost target, InetAddress local, HttpHost[] proxies, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)

Creates a new route with all attributes specified explicitly.

Parameters
target the host to which to route
local the local address to route from, or null for the default
proxies the proxy chain to use, or null for a direct route
secure true if the route is (to be) secure, false otherwise
tunnelled the tunnel type of this route
layered the layering type of this route

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

Creates a new route with at most one proxy.

Parameters
target the host to which to route
local the local address to route from, or null for the default
proxy the proxy to use, or null for a direct route
secure true if the route is (to be) secure, false otherwise
tunnelled true if the route is (to be) tunnelled via the proxy, false otherwise
layered true if the route includes a layered protocol, false otherwise

public HttpRoute (HttpHost target, InetAddress local, boolean secure)

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

Parameters
target the host to which to route
local the local address to route from, or null for the default
secure true if the route is (to be) secure, false otherwise

public HttpRoute (HttpHost target)

Creates a new direct insecure route.

Parameters
target the host to which to route

public HttpRoute (HttpHost target, InetAddress local, HttpHost proxy, 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 the host to which to route
local the local address to route from, or null for the default
proxy the proxy to use
secure true if the route is (to be) secure, false otherwise

Public Methods

public Object clone ()

Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.

Returns
  • a copy of this object.

public final boolean equals (Object o)

Compares this route to another.

Parameters
o the object to compare with
Returns
  • true if the argument is the same route, false

public final int 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
  • the number of hops in this route

public final HttpHost getHopTarget (int hop)

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 index of the hop for which to get the target, 0 for first
Returns
  • the target of the given hop

public final RouteInfo.LayerType getLayerType ()

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

Returns
  • the layering type

public final InetAddress getLocalAddress ()

Obtains the local address to connect from.

Returns
  • the local address, or null

public final HttpHost getProxyHost ()

Obtains the first proxy host.

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

public final HttpHost getTargetHost ()

Obtains the target host.

Returns
  • the target host

public final RouteInfo.TunnelType getTunnelType ()

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

Returns
  • the tunnelling type

public final int hashCode ()

Generates a hash code for this route.

Returns
  • the hash code

public final boolean 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
  • true if layered, false otherwise

public final boolean isSecure ()

Checks whether this route is secure.

Returns
  • true if secure, false otherwise

public final boolean isTunnelled ()

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

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

public final String toString ()

Obtains a description of this route.

Returns
  • a human-readable representation of this route