Package org.apache.http.conn.routing
Class RouteTracker
java.lang.Object
org.apache.http.conn.routing.RouteTracker
Helps tracking the steps in establishing a route.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.http.conn.routing.RouteInfo
RouteInfo.LayerType, RouteInfo.TunnelType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the first hop of the route is established.private RouteInfo.LayerTypeWhether the route is layered over a tunnel.private final InetAddressThe local address to connect from.private org.apache.http.HttpHost[]The proxy chain, if any.private booleanWhether the route is secure.private final org.apache.http.HttpHostThe target host to connect to.private RouteInfo.TunnelTypeWhether the the route is tunnelled end-to-end through proxies. -
Constructor Summary
ConstructorsConstructorDescriptionRouteTracker(HttpRoute route) Creates a new tracker for the given route.RouteTracker(org.apache.http.HttpHost target, InetAddress local) Creates a new route tracker. -
Method Summary
Modifier and TypeMethodDescriptionclone()voidconnectProxy(org.apache.http.HttpHost proxy, boolean secure) Tracks connecting to the first proxy.voidconnectTarget(boolean secure) Tracks connecting to the target.booleanCompares this tracked route to another.intObtains the number of hops in this route.org.apache.http.HttpHostgetHopTarget(int hop) Obtains the target of a hop in this route.Obtains the layering type of this route.Obtains the local address to connect from.org.apache.http.HttpHostObtains the first proxy host.org.apache.http.HttpHostObtains the target host.Obtains the tunnel type of this route.inthashCode()Generates a hash code for this tracked route.booleanbooleanChecks whether this route includes a layered protocol.booleanisSecure()Checks whether this route is secure.booleanChecks whether this route is tunnelled through a proxy.voidlayerProtocol(boolean secure) Tracks layering a protocol.voidreset()toRoute()Obtains the tracked route.toString()Obtains a description of the tracked route.voidtunnelProxy(org.apache.http.HttpHost proxy, boolean secure) Tracks tunnelling to a proxy in a proxy chain.voidtunnelTarget(boolean secure) Tracks tunnelling to the target.
-
Field Details
-
targetHost
private final org.apache.http.HttpHost targetHostThe target host to connect to. -
localAddress
The local address to connect from.nullindicates that the default should be used. -
connected
private boolean connectedWhether the first hop of the route is established. -
proxyChain
private org.apache.http.HttpHost[] proxyChainThe proxy chain, if any. -
tunnelled
Whether the the route is tunnelled end-to-end through proxies. -
layered
Whether the route is layered over a tunnel. -
secure
private boolean secureWhether the route is secure.
-
-
Constructor Details
-
RouteTracker
Creates a new route tracker. The target and origin need to be specified at creation time.- Parameters:
target- the host to which to routelocal- the local address to route from, ornullfor the default
-
RouteTracker
Creates a new tracker for the given route. Only target and origin are taken from the route, everything else remains to be tracked.- Parameters:
route- the route to track
-
-
Method Details
-
reset
public void reset()- Since:
- 4.2
-
connectTarget
public void connectTarget(boolean secure) Tracks connecting to the target.- Parameters:
secure-trueif the route is secure,falseotherwise
-
connectProxy
public void connectProxy(org.apache.http.HttpHost proxy, boolean secure) Tracks connecting to the first proxy.- Parameters:
proxy- the proxy connected tosecure-trueif the route is secure,falseotherwise
-
tunnelTarget
public void tunnelTarget(boolean secure) Tracks tunnelling to the target.- Parameters:
secure-trueif the route is secure,falseotherwise
-
tunnelProxy
public void tunnelProxy(org.apache.http.HttpHost proxy, boolean secure) Tracks tunnelling to a proxy in a proxy chain. This will extend the tracked proxy chain, but it does not mark the route as tunnelled. Only end-to-end tunnels are considered there.- Parameters:
proxy- the proxy tunnelled tosecure-trueif the route is secure,falseotherwise
-
layerProtocol
public void layerProtocol(boolean secure) Tracks layering a protocol.- Parameters:
secure-trueif the route is secure,falseotherwise
-
getTargetHost
public org.apache.http.HttpHost getTargetHost()Description copied from interface:RouteInfoObtains the target host.- Specified by:
getTargetHostin interfaceRouteInfo- Returns:
- the target host
-
getLocalAddress
Description copied from interface:RouteInfoObtains the local address to connect from.- Specified by:
getLocalAddressin interfaceRouteInfo- Returns:
- the local address,
or
null
-
getHopCount
public int getHopCount()Description copied from interface:RouteInfoObtains 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.- Specified by:
getHopCountin interfaceRouteInfo- Returns:
- the number of hops in this route
-
getHopTarget
public org.apache.http.HttpHost getHopTarget(int hop) Description copied from interface:RouteInfoObtains the target of a hop in this route. The target of the last hop is thetarget 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.- Specified by:
getHopTargetin interfaceRouteInfo- Parameters:
hop- index of the hop for which to get the target, 0 for first- Returns:
- the target of the given hop
-
getProxyHost
public org.apache.http.HttpHost getProxyHost()Description copied from interface:RouteInfoObtains the first proxy host.- Specified by:
getProxyHostin interfaceRouteInfo- Returns:
- the first proxy in the proxy chain, or
nullif this route is direct
-
isConnected
public boolean isConnected() -
getTunnelType
Description copied from interface:RouteInfoObtains the tunnel type of this route. If there is a proxy chain, only end-to-end tunnels are considered.- Specified by:
getTunnelTypein interfaceRouteInfo- Returns:
- the tunnelling type
-
isTunnelled
public boolean isTunnelled()Description copied from interface:RouteInfoChecks whether this route is tunnelled through a proxy. If there is a proxy chain, only end-to-end tunnels are considered.- Specified by:
isTunnelledin interfaceRouteInfo- Returns:
trueif tunnelled end-to-end through at least one proxy,falseotherwise
-
getLayerType
Description copied from interface:RouteInfoObtains the layering type of this route. In the presence of proxies, only layering over an end-to-end tunnel is considered.- Specified by:
getLayerTypein interfaceRouteInfo- Returns:
- the layering type
-
isLayered
public boolean isLayered()Description copied from interface:RouteInfoChecks whether this route includes a layered protocol. In the presence of proxies, only layering over an end-to-end tunnel is considered. -
isSecure
public boolean isSecure()Description copied from interface:RouteInfoChecks whether this route is secure. -
toRoute
Obtains the tracked route. If a route has been tracked, it isconnected. If not connected, nothing has been tracked so far.- Returns:
- the tracked route, or
nullif nothing has been tracked so far
-
equals
Compares this tracked route to another. -
hashCode
public int hashCode()Generates a hash code for this tracked route. Route trackers are modifiable and should therefore not be used as lookup keys. UsetoRouteto obtain an unmodifiable representation of the tracked route. -
toString
Obtains a description of the tracked route. -
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-