@NotThreadSafe public class DefaultRequestDirector extends Object implements org.apache.http.client.RequestDirector
Default implementation of RequestDirector
.
The following parameters can be used to customize the behavior of this class:
CoreProtocolPNames.PROTOCOL_VERSION
CoreProtocolPNames.STRICT_TRANSFER_ENCODING
CoreProtocolPNames.HTTP_ELEMENT_CHARSET
CoreProtocolPNames.USE_EXPECT_CONTINUE
CoreProtocolPNames.WAIT_FOR_CONTINUE
CoreProtocolPNames.USER_AGENT
CoreConnectionPNames.SOCKET_BUFFER_SIZE
CoreConnectionPNames.MAX_LINE_LENGTH
CoreConnectionPNames.MAX_HEADER_COUNT
CoreConnectionPNames.SO_TIMEOUT
CoreConnectionPNames.SO_LINGER
CoreConnectionPNames.TCP_NODELAY
CoreConnectionPNames.CONNECTION_TIMEOUT
CoreConnectionPNames.STALE_CONNECTION_CHECK
ConnRoutePNames.FORCED_ROUTE
ConnRoutePNames.LOCAL_ADDRESS
ConnRoutePNames.DEFAULT_PROXY
ConnManagerPNames.TIMEOUT
ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE
ConnManagerPNames.MAX_TOTAL_CONNECTIONS
org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS
org.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER
org.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET
ClientPNames.COOKIE_POLICY
ClientPNames.HANDLE_AUTHENTICATION
ClientPNames.HANDLE_REDIRECTS
ClientPNames.MAX_REDIRECTS
ClientPNames.ALLOW_CIRCULAR_REDIRECTS
ClientPNames.VIRTUAL_HOST
ClientPNames.DEFAULT_HOST
ClientPNames.DEFAULT_HEADERS
Modifier and Type | Field and Description |
---|---|
protected ClientConnectionManager |
connManager
The connection manager.
|
protected org.apache.http.protocol.HttpProcessor |
httpProcessor
The HTTP protocol processor.
|
protected ConnectionKeepAliveStrategy |
keepAliveStrategy
The keep-alive duration strategy.
|
protected ManagedClientConnection |
managedConn
The currently allocated connection.
|
protected HttpParams |
params
The HTTP parameters.
|
protected org.apache.http.client.AuthenticationHandler |
proxyAuthHandler
The proxy authentication handler.
|
protected org.apache.http.auth.AuthState |
proxyAuthState |
protected org.apache.http.client.RedirectHandler |
redirectHandler
The redirect handler.
|
protected org.apache.http.protocol.HttpRequestExecutor |
requestExec
The request executor.
|
protected org.apache.http.client.HttpRequestRetryHandler |
retryHandler
The request retry handler.
|
protected org.apache.http.ConnectionReuseStrategy |
reuseStrategy
The connection re-use strategy.
|
protected org.apache.http.conn.routing.HttpRoutePlanner |
routePlanner
The route planner.
|
protected org.apache.http.client.AuthenticationHandler |
targetAuthHandler
The target authentication handler.
|
protected org.apache.http.auth.AuthState |
targetAuthState |
protected org.apache.http.client.UserTokenHandler |
userTokenHandler
The user token handler.
|
Constructor and Description |
---|
DefaultRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
ClientConnectionManager conman,
org.apache.http.ConnectionReuseStrategy reustrat,
ConnectionKeepAliveStrategy kastrat,
org.apache.http.conn.routing.HttpRoutePlanner rouplan,
org.apache.http.protocol.HttpProcessor httpProcessor,
org.apache.http.client.HttpRequestRetryHandler retryHandler,
org.apache.http.client.RedirectHandler redirectHandler,
org.apache.http.client.AuthenticationHandler targetAuthHandler,
org.apache.http.client.AuthenticationHandler proxyAuthHandler,
org.apache.http.client.UserTokenHandler userTokenHandler,
HttpParams params) |
DefaultRequestDirector(org.apache.commons.logging.Log log,
org.apache.http.protocol.HttpRequestExecutor requestExec,
ClientConnectionManager conman,
org.apache.http.ConnectionReuseStrategy reustrat,
ConnectionKeepAliveStrategy kastrat,
org.apache.http.conn.routing.HttpRoutePlanner rouplan,
org.apache.http.protocol.HttpProcessor httpProcessor,
org.apache.http.client.HttpRequestRetryHandler retryHandler,
org.apache.http.client.RedirectHandler redirectHandler,
org.apache.http.client.AuthenticationHandler targetAuthHandler,
org.apache.http.client.AuthenticationHandler proxyAuthHandler,
org.apache.http.client.UserTokenHandler userTokenHandler,
HttpParams params) |
Modifier and Type | Method and Description |
---|---|
protected org.apache.http.HttpRequest |
createConnectRequest(org.apache.http.conn.routing.HttpRoute route,
org.apache.http.protocol.HttpContext context)
Creates the CONNECT request for tunnelling.
|
protected boolean |
createTunnelToProxy(org.apache.http.conn.routing.HttpRoute route,
int hop,
org.apache.http.protocol.HttpContext context)
Creates a tunnel to an intermediate proxy.
|
protected boolean |
createTunnelToTarget(org.apache.http.conn.routing.HttpRoute route,
org.apache.http.protocol.HttpContext context)
Creates a tunnel to the target server.
|
protected org.apache.http.conn.routing.HttpRoute |
determineRoute(org.apache.http.HttpHost target,
org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context)
Determines the route for a request.
|
protected void |
establishRoute(org.apache.http.conn.routing.HttpRoute route,
org.apache.http.protocol.HttpContext context)
Establishes the target route.
|
org.apache.http.HttpResponse |
execute(org.apache.http.HttpHost target,
org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context) |
protected org.apache.http.impl.client.RoutedRequest |
handleResponse(org.apache.http.impl.client.RoutedRequest roureq,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context)
Analyzes a response to check need for a followup.
|
protected void |
releaseConnection()
Returns the connection back to the connection manager and prepares for retrieving a new connection during the next request.
|
protected void |
rewriteRequestURI(org.apache.http.impl.client.RequestWrapper request,
org.apache.http.conn.routing.HttpRoute route) |
protected final ClientConnectionManager connManager
The connection manager.
protected final org.apache.http.conn.routing.HttpRoutePlanner routePlanner
The route planner.
protected final org.apache.http.ConnectionReuseStrategy reuseStrategy
The connection re-use strategy.
protected final ConnectionKeepAliveStrategy keepAliveStrategy
The keep-alive duration strategy.
protected final org.apache.http.protocol.HttpRequestExecutor requestExec
The request executor.
protected final org.apache.http.protocol.HttpProcessor httpProcessor
The HTTP protocol processor.
protected final org.apache.http.client.HttpRequestRetryHandler retryHandler
The request retry handler.
protected final org.apache.http.client.RedirectHandler redirectHandler
The redirect handler.
protected final org.apache.http.client.AuthenticationHandler targetAuthHandler
The target authentication handler.
protected final org.apache.http.client.AuthenticationHandler proxyAuthHandler
The proxy authentication handler.
protected final org.apache.http.client.UserTokenHandler userTokenHandler
The user token handler.
protected final HttpParams params
The HTTP parameters.
protected ManagedClientConnection managedConn
The currently allocated connection.
protected final org.apache.http.auth.AuthState targetAuthState
protected final org.apache.http.auth.AuthState proxyAuthState
public DefaultRequestDirector(org.apache.commons.logging.Log log, org.apache.http.protocol.HttpRequestExecutor requestExec, ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, org.apache.http.conn.routing.HttpRoutePlanner rouplan, org.apache.http.protocol.HttpProcessor httpProcessor, org.apache.http.client.HttpRequestRetryHandler retryHandler, org.apache.http.client.RedirectHandler redirectHandler, org.apache.http.client.AuthenticationHandler targetAuthHandler, org.apache.http.client.AuthenticationHandler proxyAuthHandler, org.apache.http.client.UserTokenHandler userTokenHandler, HttpParams params)
public DefaultRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec, ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, org.apache.http.conn.routing.HttpRoutePlanner rouplan, org.apache.http.protocol.HttpProcessor httpProcessor, org.apache.http.client.HttpRequestRetryHandler retryHandler, org.apache.http.client.RedirectHandler redirectHandler, org.apache.http.client.AuthenticationHandler targetAuthHandler, org.apache.http.client.AuthenticationHandler proxyAuthHandler, org.apache.http.client.UserTokenHandler userTokenHandler, HttpParams params)
protected void rewriteRequestURI(org.apache.http.impl.client.RequestWrapper request, org.apache.http.conn.routing.HttpRoute route) throws org.apache.http.ProtocolException
org.apache.http.ProtocolException
public org.apache.http.HttpResponse execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context) throws org.apache.http.HttpException, IOException
execute
in interface org.apache.http.client.RequestDirector
org.apache.http.HttpException
IOException
protected void releaseConnection()
Returns the connection back to the connection manager and prepares for retrieving a new connection during the next request.
protected org.apache.http.conn.routing.HttpRoute determineRoute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context) throws org.apache.http.HttpException
Determines the route for a request. Called by execute(org.apache.http.HttpHost, org.apache.http.HttpRequest, org.apache.http.protocol.HttpContext)
to determine the route for either the original or a followup request.
target
- the target host for the request. Implementations may accept null
if they can still determine a route, for example to a default target or by inspecting the request.request
- the request to executecontext
- the context to use for the execution, never null
org.apache.http.HttpException
- in case of a problemprotected void establishRoute(org.apache.http.conn.routing.HttpRoute route, org.apache.http.protocol.HttpContext context) throws org.apache.http.HttpException, IOException
Establishes the target route.
route
- the route to establishcontext
- the context for the request executionorg.apache.http.HttpException
- in case of a problemIOException
- in case of an IO problemprotected boolean createTunnelToTarget(org.apache.http.conn.routing.HttpRoute route, org.apache.http.protocol.HttpContext 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.
route
- the route to establishcontext
- the context for request executiontrue
if the tunnelled route is secure, false
otherwise. The implementation here always returns false
, but derived classes may override.org.apache.http.HttpException
- in case of a problemIOException
- in case of an IO problemprotected boolean createTunnelToProxy(org.apache.http.conn.routing.HttpRoute route, int hop, org.apache.http.protocol.HttpContext context) throws org.apache.http.HttpException, IOException
Creates a tunnel to an intermediate proxy. This method is not implemented in this class. It just throws an exception here.
route
- the route to establishhop
- the hop in the route to establish now. route.getHopTarget(hop)
will return the proxy to tunnel to.context
- the context for request executiontrue
if the partially tunnelled connection is secure, false
otherwise.org.apache.http.HttpException
- in case of a problemIOException
- in case of an IO problemprotected org.apache.http.HttpRequest createConnectRequest(org.apache.http.conn.routing.HttpRoute route, org.apache.http.protocol.HttpContext context)
Creates the CONNECT request for tunnelling. Called by createTunnelToTarget
.
route
- the route to establishcontext
- the context for request executionprotected org.apache.http.impl.client.RoutedRequest handleResponse(org.apache.http.impl.client.RoutedRequest roureq, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context) throws org.apache.http.HttpException, IOException
Analyzes a response to check need for a followup.
roureq
- the request and route.response
- the response to analayzecontext
- the context used for the current request executionnull
if the response should be returned as isorg.apache.http.HttpException
- in case of a problemIOException
- in case of an IO problem