Package org.apache.hc.client5.http
Class HttpRoute
- java.lang.Object
-
- org.apache.hc.client5.http.HttpRoute
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.hc.client5.http.RouteInfo
RouteInfo.LayerType, RouteInfo.TunnelType
-
-
Field Summary
Fields Modifier and Type Field Description private RouteInfo.LayerTypelayeredWhether the route is layered.private java.net.InetAddresslocalAddressThe local address to connect from.private java.util.List<org.apache.hc.core5.http.HttpHost>proxyChainThe proxy servers, if any.private booleansecureWhether the route is (supposed to be) secure.private org.apache.hc.core5.http.HttpHosttargetHostThe target host to connect to.private org.apache.hc.core5.net.NamedEndpointtargetNameThe target name, if different from the target host,nullotherwise.private RouteInfo.TunnelTypetunnelledWhether the the route is tunnelled through the proxy.private java.nio.file.PathunixDomainSocketThe path to the UDS to connect to, if any.
-
Constructor Summary
Constructors Constructor Description HttpRoute(org.apache.hc.core5.http.HttpHost target)Creates a new direct insecure route.HttpRoute(org.apache.hc.core5.http.HttpHost target, boolean secure, java.nio.file.Path unixDomainSocket)Creates a new direct route that connects over a Unix domain socket rather than TCP.HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, boolean secure)Creates a new direct route.HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, org.apache.hc.core5.http.HttpHost[] proxies, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)Creates a new route with all attributes specified explicitly.HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, org.apache.hc.core5.http.HttpHost proxy, boolean secure)Creates a new route through a proxy.HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, org.apache.hc.core5.http.HttpHost proxy, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)Creates a new route with at most one proxy.HttpRoute(org.apache.hc.core5.http.HttpHost target, java.nio.file.Path unixDomainSocket)Creates a new direct route that connects over a Unix domain socket rather than TCP.HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpHost proxy)Creates a new plain route through a proxy.HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, boolean secure)Creates a new direct route.HttpRoute(org.apache.hc.core5.http.HttpHost targetHost, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, java.util.List<org.apache.hc.core5.http.HttpHost> proxies, java.nio.file.Path unixDomainSocket, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, org.apache.hc.core5.http.HttpHost[] proxies, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)Creates a new route with all attributes specified explicitly.HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, org.apache.hc.core5.http.HttpHost proxy, boolean secure)Creates a new route through a proxy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleanequals(java.lang.Object obj)Compares this route to another.intgetHopCount()Obtains the number of hops in this route.org.apache.hc.core5.http.HttpHostgetHopTarget(int hop)Obtains the target of a hop in this route.RouteInfo.LayerTypegetLayerType()Obtains the layering type of this route.java.net.InetAddressgetLocalAddress()Obtains the local address to connect from.java.net.InetSocketAddressgetLocalSocketAddress()org.apache.hc.core5.http.HttpHostgetProxyHost()Obtains the first proxy host.org.apache.hc.core5.http.HttpHostgetTargetHost()Obtains the target host.org.apache.hc.core5.net.NamedEndpointgetTargetName()Obtains the target name, if different from the target host,nullotherwise.RouteInfo.TunnelTypegetTunnelType()Obtains the tunnel type of this route.java.nio.file.PathgetUnixDomainSocket()Obtains the Unix domain socket through which to connect to the target host.inthashCode()Generates a hash code for this route.booleanisLayered()Checks whether this route includes a layered protocol.booleanisSecure()Checks whether this route is secure.booleanisTunnelled()Checks whether this route is tunnelled through a proxy.java.lang.StringtoString()Obtains a description of this route.private voidvalidateUdsArguments()
-
-
-
Field Detail
-
targetHost
private final org.apache.hc.core5.http.HttpHost targetHost
The target host to connect to.
-
targetName
private final org.apache.hc.core5.net.NamedEndpoint targetName
The target name, if different from the target host,nullotherwise.
-
localAddress
private final java.net.InetAddress localAddress
The local address to connect from.nullindicates that the default should be used.
-
proxyChain
private final java.util.List<org.apache.hc.core5.http.HttpHost> proxyChain
The proxy servers, if any. Never null.
-
unixDomainSocket
private final java.nio.file.Path unixDomainSocket
The path to the UDS to connect to, if any.
-
tunnelled
private final RouteInfo.TunnelType tunnelled
Whether the the route is tunnelled through the proxy.
-
layered
private final RouteInfo.LayerType layered
Whether the route is layered.
-
secure
private final boolean secure
Whether the route is (supposed to be) secure.
-
-
Constructor Detail
-
HttpRoute
HttpRoute(org.apache.hc.core5.http.HttpHost targetHost, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, java.util.List<org.apache.hc.core5.http.HttpHost> proxies, java.nio.file.Path unixDomainSocket, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, org.apache.hc.core5.http.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 routelocal- the local address to route from, ornullfor the defaultproxies- the proxy chain to use, ornullfor a direct routesecure-trueif the route is (to be) secure,falseotherwisetunnelled- the tunnel type of this routelayered- the layering type of this route
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, org.apache.hc.core5.http.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 routetargetName- the target targetName if differs from the target host.local- the local address to route from, ornullfor the defaultproxies- the proxy chain to use, ornullfor a direct routesecure-trueif the route is (to be) secure,falseotherwisetunnelled- the tunnel type of this routelayered- the layering type of this route- Since:
- 5.4
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, org.apache.hc.core5.http.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 routelocal- the local address to route from, ornullfor the defaultproxy- the proxy to use, ornullfor a direct routesecure-trueif the route is (to be) secure,falseotherwisetunnelled-trueif the route is (to be) tunnelled via the proxy,falseotherwiselayered-trueif the route includes a layered protocol,falseotherwise
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, boolean secure)Creates a new direct route. That is a route without a proxy.- Parameters:
target- the host to which to routelocal- the local address to route from, ornullfor the defaultsecure-trueif the route is (to be) secure,falseotherwise
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, boolean secure)Creates a new direct route. That is a route without a proxy.- Parameters:
target- the host to which to routetargetName- the target targetName if differs from the target host.local- the local address to route from, ornullfor the defaultsecure-trueif the route is (to be) secure,falseotherwise- Since:
- 5.4
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, java.nio.file.Path unixDomainSocket)Creates a new direct route that connects over a Unix domain socket rather than TCP.- Parameters:
target- the host to which to routeunixDomainSocket- the path to the Unix domain socket- Since:
- 5.6
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, boolean secure, java.nio.file.Path unixDomainSocket)Creates a new direct route that connects over a Unix domain socket rather than TCP.- Parameters:
target- the host to which to routesecure-trueif the route is (to be) secure,falseotherwiseunixDomainSocket- the path to the Unix domain socket- Since:
- 5.6
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target)
Creates a new direct insecure route.- Parameters:
target- the host to which to route
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.net.NamedEndpoint targetName, java.net.InetAddress local, org.apache.hc.core5.http.HttpHost proxy, boolean secure)Creates a new route through a proxy. When using this constructor, theproxyMUST 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 routetargetName- the target targetName if differs from the target host.local- the local address to route from, ornullfor the defaultproxy- the proxy to usesecure-trueif the route is (to be) secure,falseotherwise- Since:
- 5.4
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, java.net.InetAddress local, org.apache.hc.core5.http.HttpHost proxy, boolean secure)Creates a new route through a proxy. When using this constructor, theproxyMUST 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 routelocal- the local address to route from, ornullfor the defaultproxy- the proxy to usesecure-trueif the route is (to be) secure,falseotherwise
-
HttpRoute
public HttpRoute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpHost proxy)Creates a new plain route through a proxy.- Parameters:
target- the host to which to routeproxy- the proxy to use- Since:
- 4.3
-
-
Method Detail
-
validateUdsArguments
private void validateUdsArguments()
-
getTargetHost
public org.apache.hc.core5.http.HttpHost getTargetHost()
Description copied from interface:RouteInfoObtains the target host.- Specified by:
getTargetHostin interfaceRouteInfo- Returns:
- the target host
-
getTargetName
public org.apache.hc.core5.net.NamedEndpoint getTargetName()
Description copied from interface:RouteInfoObtains the target name, if different from the target host,nullotherwise.- Specified by:
getTargetNamein interfaceRouteInfo- Since:
- 5.4
-
getLocalAddress
public java.net.InetAddress getLocalAddress()
Description copied from interface:RouteInfoObtains the local address to connect from.- Specified by:
getLocalAddressin interfaceRouteInfo- Returns:
- the local address,
or
null
-
getLocalSocketAddress
public java.net.InetSocketAddress getLocalSocketAddress()
-
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.hc.core5.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.hc.core5.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
-
getUnixDomainSocket
public java.nio.file.Path getUnixDomainSocket()
Description copied from interface:RouteInfoObtains the Unix domain socket through which to connect to the target host.- Specified by:
getUnixDomainSocketin interfaceRouteInfo- Returns:
- the path to the Unix domain socket, or
nullif none
-
getTunnelType
public RouteInfo.TunnelType 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
public RouteInfo.LayerType 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.
-
equals
public boolean equals(java.lang.Object obj)
Compares this route to another.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare with- Returns:
trueif the argument is the same route,false
-
hashCode
public int hashCode()
Generates a hash code for this route.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash code
-
toString
public java.lang.String toString()
Obtains a description of this route.- Overrides:
toStringin classjava.lang.Object- Returns:
- a human-readable representation of this route
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-