Package org.apache.http.impl.execchain
Class MainClientExec
- java.lang.Object
-
- org.apache.http.impl.execchain.MainClientExec
-
- All Implemented Interfaces:
ClientExecChain
@Contract(threading=IMMUTABLE_CONDITIONAL) public class MainClientExec extends java.lang.Object implements ClientExecChain
The last request executor in the HTTP request execution chain that is responsible for execution of request / response exchanges with the opposite endpoint. This executor will automatically retry the request in case of an authentication challenge by an intermediate proxy or by the target server.- Since:
- 4.3
-
-
Field Summary
Fields Modifier and Type Field Description private HttpAuthenticator
authenticator
private HttpClientConnectionManager
connManager
private ConnectionKeepAliveStrategy
keepAliveStrategy
private org.apache.commons.logging.Log
log
private AuthenticationStrategy
proxyAuthStrategy
private org.apache.http.protocol.HttpProcessor
proxyHttpProcessor
private org.apache.http.protocol.HttpRequestExecutor
requestExecutor
private org.apache.http.ConnectionReuseStrategy
reuseStrategy
private HttpRouteDirector
routeDirector
private AuthenticationStrategy
targetAuthStrategy
private UserTokenHandler
userTokenHandler
-
Constructor Summary
Constructors Constructor Description MainClientExec(org.apache.http.protocol.HttpRequestExecutor requestExecutor, HttpClientConnectionManager connManager, org.apache.http.ConnectionReuseStrategy reuseStrategy, ConnectionKeepAliveStrategy keepAliveStrategy, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler)
MainClientExec(org.apache.http.protocol.HttpRequestExecutor requestExecutor, HttpClientConnectionManager connManager, org.apache.http.ConnectionReuseStrategy reuseStrategy, ConnectionKeepAliveStrategy keepAliveStrategy, org.apache.http.protocol.HttpProcessor proxyHttpProcessor, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
createTunnelToProxy(HttpRoute route, int hop, HttpClientContext context)
Creates a tunnel to an intermediate proxy.private boolean
createTunnelToTarget(AuthState proxyAuthState, org.apache.http.HttpClientConnection managedConn, HttpRoute route, org.apache.http.HttpRequest request, HttpClientContext context)
Creates a tunnel to the target server.(package private) void
establishRoute(AuthState proxyAuthState, org.apache.http.HttpClientConnection managedConn, HttpRoute route, org.apache.http.HttpRequest request, HttpClientContext context)
Establishes the target route.CloseableHttpResponse
execute(HttpRoute route, HttpRequestWrapper request, HttpClientContext context, HttpExecutionAware execAware)
Executes th request either by transmitting it to the target server or by passing it onto the next executor in the request execution chain.private boolean
needAuthentication(AuthState targetAuthState, AuthState proxyAuthState, HttpRoute route, org.apache.http.HttpResponse response, HttpClientContext context)
-
-
-
Field Detail
-
log
private final org.apache.commons.logging.Log log
-
requestExecutor
private final org.apache.http.protocol.HttpRequestExecutor requestExecutor
-
connManager
private final HttpClientConnectionManager connManager
-
reuseStrategy
private final org.apache.http.ConnectionReuseStrategy reuseStrategy
-
keepAliveStrategy
private final ConnectionKeepAliveStrategy keepAliveStrategy
-
proxyHttpProcessor
private final org.apache.http.protocol.HttpProcessor proxyHttpProcessor
-
targetAuthStrategy
private final AuthenticationStrategy targetAuthStrategy
-
proxyAuthStrategy
private final AuthenticationStrategy proxyAuthStrategy
-
authenticator
private final HttpAuthenticator authenticator
-
userTokenHandler
private final UserTokenHandler userTokenHandler
-
routeDirector
private final HttpRouteDirector routeDirector
-
-
Constructor Detail
-
MainClientExec
public MainClientExec(org.apache.http.protocol.HttpRequestExecutor requestExecutor, HttpClientConnectionManager connManager, org.apache.http.ConnectionReuseStrategy reuseStrategy, ConnectionKeepAliveStrategy keepAliveStrategy, org.apache.http.protocol.HttpProcessor proxyHttpProcessor, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler)
- Since:
- 4.4
-
MainClientExec
public MainClientExec(org.apache.http.protocol.HttpRequestExecutor requestExecutor, HttpClientConnectionManager connManager, org.apache.http.ConnectionReuseStrategy reuseStrategy, ConnectionKeepAliveStrategy keepAliveStrategy, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler)
-
-
Method Detail
-
execute
public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request, HttpClientContext context, HttpExecutionAware execAware) throws java.io.IOException, org.apache.http.HttpException
Description copied from interface:ClientExecChain
Executes th request either by transmitting it to the target server or by passing it onto the next executor in the request execution chain.- Specified by:
execute
in interfaceClientExecChain
- Parameters:
route
- connection route.request
- current request.context
- current HTTP context.execAware
- receiver of notifications of blocking I/O operations.- Returns:
- HTTP response either received from the opposite endpoint or generated locally.
- Throws:
java.io.IOException
- in case of a I/O error. (this type of exceptions are potentially recoverable).org.apache.http.HttpException
- in case of an HTTP protocol error (usually this type of exceptions are non-recoverable).
-
establishRoute
void establishRoute(AuthState proxyAuthState, org.apache.http.HttpClientConnection managedConn, HttpRoute route, org.apache.http.HttpRequest request, HttpClientContext context) throws org.apache.http.HttpException, java.io.IOException
Establishes the target route.- Throws:
org.apache.http.HttpException
java.io.IOException
-
createTunnelToTarget
private boolean createTunnelToTarget(AuthState proxyAuthState, org.apache.http.HttpClientConnection managedConn, HttpRoute route, org.apache.http.HttpRequest request, HttpClientContext context) throws org.apache.http.HttpException, java.io.IOException
Creates a tunnel to the target server. The connection must be established to the (last) proxy. A CONNECT request for tunnelling through the proxy will be created and sent, the response received and checked. This method does not update the connection with information about the tunnel, that is left to the caller.- Throws:
org.apache.http.HttpException
java.io.IOException
-
createTunnelToProxy
private boolean createTunnelToProxy(HttpRoute route, int hop, HttpClientContext context) throws org.apache.http.HttpException
Creates a tunnel to an intermediate proxy. This method is not implemented in this class. It just throws an exception here.- Throws:
org.apache.http.HttpException
-
needAuthentication
private boolean needAuthentication(AuthState targetAuthState, AuthState proxyAuthState, HttpRoute route, org.apache.http.HttpResponse response, HttpClientContext context)
-
-