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 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
FieldsModifier and TypeFieldDescriptionprivate final HttpAuthenticator
private final HttpClientConnectionManager
private final ConnectionKeepAliveStrategy
private final org.apache.commons.logging.Log
private final AuthenticationStrategy
private final org.apache.http.protocol.HttpProcessor
private final org.apache.http.protocol.HttpRequestExecutor
private final org.apache.http.ConnectionReuseStrategy
private final HttpRouteDirector
private final AuthenticationStrategy
private final UserTokenHandler
-
Constructor Summary
ConstructorsConstructorDescriptionMainClientExec
(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
Modifier and TypeMethodDescriptionprivate 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.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 Details
-
log
private final org.apache.commons.logging.Log log -
requestExecutor
private final org.apache.http.protocol.HttpRequestExecutor requestExecutor -
connManager
-
reuseStrategy
private final org.apache.http.ConnectionReuseStrategy reuseStrategy -
keepAliveStrategy
-
proxyHttpProcessor
private final org.apache.http.protocol.HttpProcessor proxyHttpProcessor -
targetAuthStrategy
-
proxyAuthStrategy
-
authenticator
-
userTokenHandler
-
routeDirector
-
-
Constructor Details
-
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 Details
-
execute
public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request, HttpClientContext context, HttpExecutionAware execAware) throws 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:
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, IOException Establishes the target route.- Throws:
org.apache.http.HttpException
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, 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
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)
-