Top Description Fields Constructors Methods
org.apache.http.impl.client

public Class DefaultRequestDirector

extends Object
implements RequestDirector
Class Inheritance
All Implemented Interfaces
org.apache.http.client.RequestDirector
Annotations
@Deprecated
Imports
java.io.IOException, .InterruptedIOException, java.net.URI, .URISyntaxException, java.util.concurrent.TimeUnit, org.apache.commons.logging.Log, .LogFactory, org.apache.http.ConnectionReuseStrategy, .HttpEntity, .HttpEntityEnclosingRequest, .HttpException, .HttpHost, .HttpRequest, .HttpResponse, .NoHttpResponseException, .ProtocolException, .ProtocolVersion, org.apache.http.auth.AuthProtocolState, .AuthScheme, .AuthState, .UsernamePasswordCredentials, org.apache.http.client.AuthenticationHandler, .AuthenticationStrategy, .HttpRequestRetryHandler, .NonRepeatableRequestException, .RedirectException, .RedirectHandler, .RedirectStrategy, .RequestDirector, .UserTokenHandler, org.apache.http.client.methods.AbortableHttpRequest, .HttpUriRequest, org.apache.http.client.params.ClientPNames, .HttpClientParams, org.apache.http.client.protocol.ClientContext, org.apache.http.client.utils.URIUtils, org.apache.http.conn.BasicManagedEntity, .ClientConnectionManager, .ClientConnectionRequest, .ConnectionKeepAliveStrategy, .ManagedClientConnection, org.apache.http.conn.routing.BasicRouteDirector, .HttpRoute, .HttpRouteDirector, .HttpRoutePlanner, org.apache.http.conn.scheme.Scheme, org.apache.http.entity.BufferedHttpEntity, org.apache.http.impl.auth.BasicScheme, org.apache.http.impl.conn.ConnectionShutdownException, org.apache.http.message.BasicHttpRequest, org.apache.http.params.HttpConnectionParams, .HttpParams, .HttpProtocolParams, org.apache.http.protocol.ExecutionContext, .HttpContext, .HttpProcessor, .HttpRequestExecutor, org.apache.http.util.Args, .EntityUtils

Deprecated

Do not use.

Default implementation of RequestDirector.

The following parameters can be used to customize the behavior of this class:

Since
4.0

Field Summary

Modifier and TypeField and Description
private final HttpAuthenticator
authenticator

Deprecated as a consequence of HttpAuthenticator being deprecated.
protected final ClientConnectionManager
connManager

The connection manager.

private int
protected final HttpProcessor
httpProcessor

The HTTP protocol processor.

protected final ConnectionKeepAliveStrategy
keepAliveStrategy

The keep-alive duration strategy.

private final Log
protected ManagedClientConnection
managedConn

The currently allocated connection.

private final int
protected final HttpParams
params

The HTTP parameters.

protected final AuthenticationHandler
proxyAuthHandler

The proxy authentication handler.

protected final AuthState
protected final AuthenticationStrategy
proxyAuthStrategy

The proxy authentication handler.

private int
protected final RedirectHandler
redirectHandler

The redirect handler.

protected final RedirectStrategy
redirectStrategy

The redirect strategy.

protected final HttpRequestExecutor
requestExec

The request executor.

protected final HttpRequestRetryHandler
retryHandler

The request retry handler.

protected final ConnectionReuseStrategy
reuseStrategy

The connection re-use strategy.

protected final HttpRoutePlanner
routePlanner

The route planner.

protected final AuthenticationHandler
targetAuthHandler

The target authentication handler.

protected final AuthState
protected final AuthenticationStrategy
targetAuthStrategy

The target authentication handler.

protected final UserTokenHandler
userTokenHandler

The user token handler.

private HttpHost

Constructor Summary

AccessConstructor and Description
public
DefaultRequestDirector(final HttpRequestExecutor requestExec, final ClientConnectionManager conman, final ConnectionReuseStrategy reustrat, final ConnectionKeepAliveStrategy kastrat, final HttpRoutePlanner rouplan, final HttpProcessor httpProcessor, final HttpRequestRetryHandler retryHandler, final RedirectHandler redirectHandler, final AuthenticationHandler targetAuthHandler, final AuthenticationHandler proxyAuthHandler, final UserTokenHandler userTokenHandler, final HttpParams params)

Deprecated as a consequence of ClientConnectionManager, RedirectHandler, AuthenticationHandler and HttpParams being deprecated.
public
DefaultRequestDirector(final Log log, final HttpRequestExecutor requestExec, final ClientConnectionManager conman, final ConnectionReuseStrategy reustrat, final ConnectionKeepAliveStrategy kastrat, final HttpRoutePlanner rouplan, final HttpProcessor httpProcessor, final HttpRequestRetryHandler retryHandler, final RedirectStrategy redirectStrategy, final AuthenticationHandler targetAuthHandler, final AuthenticationHandler proxyAuthHandler, final UserTokenHandler userTokenHandler, final HttpParams params)

Deprecated as a consequence of ClientConnectionManager, AuthenticationHandler and HttpParams being deprecated.
public
DefaultRequestDirector(final Log log, final HttpRequestExecutor requestExec, final ClientConnectionManager conman, final ConnectionReuseStrategy reustrat, final ConnectionKeepAliveStrategy kastrat, final HttpRoutePlanner rouplan, final HttpProcessor httpProcessor, final HttpRequestRetryHandler retryHandler, final RedirectStrategy redirectStrategy, final AuthenticationStrategy targetAuthStrategy, final AuthenticationStrategy proxyAuthStrategy, final UserTokenHandler userTokenHandler, final HttpParams params)

Deprecated as a consequence of ClientConnectionManager and HttpParams being deprecated.

Method Summary

Modifier and TypeMethod and Description
private void
abortConnection()

Shuts down the connection.

protected HttpRequest

Returns:

the CONNECT request for tunnelling
createConnectRequest
(final HttpRoute
the route to establish
route
,
final HttpContext
the context for request execution
context
)

Creates the CONNECT request for tunnelling.

protected boolean

Returns:

true if the partially tunnelled connection is secure, false otherwise.
createTunnelToProxy
(final HttpRoute
the route to establish
route
,
final int
the hop in the route to establish now. route.getHopTarget(hop) will return the proxy to tunnel to.
hop
,
final HttpContext
the context for request execution
context
)

Creates a tunnel to an intermediate proxy.

protected boolean

Returns:

true if the tunnelled route is secure, false otherwise. The implementation here always returns false, but derived classes may override.
createTunnelToTarget
(final HttpRoute
the route to establish
route
,
final HttpContext
the context for request execution
context
)

Creates a tunnel to the target server.

protected HttpRoute

Returns:

the route the request should take
determineRoute
(final HttpHost
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.
targetHost
,
final HttpRequest
the request to execute
request
,
final HttpContext
the context to use for the execution, never null
context
)

Determines the route for a request.

protected void
establishRoute(final HttpRoute
the route to establish
route
,
final HttpContext
the context for the request execution
context
)

Establishes the target route.

public HttpResponse
execute(final HttpHost
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.
targetHost
,
final HttpRequest
the request to execute
request
,
final HttpContext
the context for executing the request
context
)

Implements org.apache.http.client.RequestDirector.execute.

Executes a request.
protected RoutedRequest

Returns:

the followup request and route if there is a followup, or null if the response should be returned as is
handleResponse
(final RoutedRequest
the request and route.
roureq
,
final HttpResponse
the response to analayze
response
,
final HttpContext
the context used for the current request execution
context
)

Deprecated as a consequence of RoutedRequest being deprecated.
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(final RequestWrapper request, final HttpRoute route)

Deprecated as a consequence of RequestWrapper being deprecated.
private void
tryConnect(final RoutedRequest req, final HttpContext context)

Deprecated as a consequence of RoutedRequest being deprecated.
Establish connection either directly or through a tunnel and retry in case of a recoverable I/O failure
private HttpResponse
tryExecute(final RoutedRequest req, final HttpContext context)

Deprecated as a consequence of RoutedRequest being deprecated.
Execute request and retry in case of a recoverable I/O failure
private RequestWrapper
wrapRequest(final HttpRequest request)

Deprecated as a consequence of RequestWrapper being deprecated.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

authenticatorback to summary
private final HttpAuthenticator authenticator

Deprecated

as a consequence of HttpAuthenticator being deprecated. See corresponding docs for further information.

connManagerback to summary
protected final ClientConnectionManager connManager

Deprecated

as a consequence of ClientConnectionManager being deprecated. See corresponding docs for further information.

The connection manager.

execCountback to summary
private int execCount
httpProcessorback to summary
protected final HttpProcessor httpProcessor

The HTTP protocol processor.

keepAliveStrategyback to summary
protected final ConnectionKeepAliveStrategy keepAliveStrategy

The keep-alive duration strategy.

logback to summary
private final Log log
managedConnback to summary
protected ManagedClientConnection managedConn

Deprecated

as a consequence of ManagedClientConnection being deprecated. See corresponding docs for further information.

The currently allocated connection.

maxRedirectsback to summary
private final int maxRedirects
paramsback to summary
protected final HttpParams params

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

The HTTP parameters.

proxyAuthHandlerback to summary
protected final AuthenticationHandler proxyAuthHandler

Deprecated

as a consequence of AuthenticationHandler being deprecated. See corresponding docs for further information.

The proxy authentication handler.

proxyAuthStateback to summary
protected final AuthState proxyAuthState
proxyAuthStrategyback to summary
protected final AuthenticationStrategy proxyAuthStrategy

The proxy authentication handler.

redirectCountback to summary
private int redirectCount
redirectHandlerback to summary
protected final RedirectHandler redirectHandler

Deprecated

as a consequence of RedirectHandler being deprecated. See corresponding docs for further information.

The redirect handler.

redirectStrategyback to summary
protected final RedirectStrategy redirectStrategy

The redirect strategy.

requestExecback to summary
protected final HttpRequestExecutor requestExec

The request executor.

retryHandlerback to summary
protected final HttpRequestRetryHandler retryHandler

The request retry handler.

reuseStrategyback to summary
protected final ConnectionReuseStrategy reuseStrategy

The connection re-use strategy.

routePlannerback to summary
protected final HttpRoutePlanner routePlanner

The route planner.

targetAuthHandlerback to summary
protected final AuthenticationHandler targetAuthHandler

Deprecated

as a consequence of AuthenticationHandler being deprecated. See corresponding docs for further information.

The target authentication handler.

targetAuthStateback to summary
protected final AuthState targetAuthState
targetAuthStrategyback to summary
protected final AuthenticationStrategy targetAuthStrategy

The target authentication handler.

userTokenHandlerback to summary
protected final UserTokenHandler userTokenHandler

The user token handler.

virtualHostback to summary
private HttpHost virtualHost

Constructor Detail

DefaultRequestDirectorback to summary
public DefaultRequestDirector(final HttpRequestExecutor requestExec, final ClientConnectionManager conman, final ConnectionReuseStrategy reustrat, final ConnectionKeepAliveStrategy kastrat, final HttpRoutePlanner rouplan, final HttpProcessor httpProcessor, final HttpRequestRetryHandler retryHandler, final RedirectHandler redirectHandler, final AuthenticationHandler targetAuthHandler, final AuthenticationHandler proxyAuthHandler, final UserTokenHandler userTokenHandler, final HttpParams params)

Deprecated

as a consequence of ClientConnectionManager, RedirectHandler, AuthenticationHandler and HttpParams being deprecated. See corresponding docs for further information.

DefaultRequestDirectorback to summary
public DefaultRequestDirector(final Log log, final HttpRequestExecutor requestExec, final ClientConnectionManager conman, final ConnectionReuseStrategy reustrat, final ConnectionKeepAliveStrategy kastrat, final HttpRoutePlanner rouplan, final HttpProcessor httpProcessor, final HttpRequestRetryHandler retryHandler, final RedirectStrategy redirectStrategy, final AuthenticationHandler targetAuthHandler, final AuthenticationHandler proxyAuthHandler, final UserTokenHandler userTokenHandler, final HttpParams params)

Deprecated

as a consequence of ClientConnectionManager, AuthenticationHandler and HttpParams being deprecated. See corresponding docs for further information.

DefaultRequestDirectorback to summary
public DefaultRequestDirector(final Log log, final HttpRequestExecutor requestExec, final ClientConnectionManager conman, final ConnectionReuseStrategy reustrat, final ConnectionKeepAliveStrategy kastrat, final HttpRoutePlanner rouplan, final HttpProcessor httpProcessor, final HttpRequestRetryHandler retryHandler, final RedirectStrategy redirectStrategy, final AuthenticationStrategy targetAuthStrategy, final AuthenticationStrategy proxyAuthStrategy, final UserTokenHandler userTokenHandler, final HttpParams params)

Deprecated

as a consequence of ClientConnectionManager and HttpParams being deprecated. See corresponding docs for further information.

Since
4.2

Method Detail

abortConnectionback to summary
private void abortConnection()

Shuts down the connection. This method is called from a catch block in execute during exception handling.

createConnectRequestback to summary
protected HttpRequest createConnectRequest(final HttpRoute route, final HttpContext context)

Creates the CONNECT request for tunnelling. Called by createTunnelToTarget.

Parameters
route:HttpRoute

the route to establish

context:HttpContext

the context for request execution

Returns:HttpRequest

the CONNECT request for tunnelling

createTunnelToProxyback to summary
protected boolean createTunnelToProxy(final HttpRoute route, final int hop, final HttpContext context) throws HttpException, IOException

Creates a tunnel to an intermediate proxy. This method is not implemented in this class. It just throws an exception here.

Parameters
route:HttpRoute

the route to establish

hop:int

the hop in the route to establish now. route.getHopTarget(hop) will return the proxy to tunnel to.

context:HttpContext

the context for request execution

Returns:boolean

true if the partially tunnelled connection is secure, false otherwise.

Exceptions
HttpException:
in case of a problem
IOException:
in case of an IO problem
createTunnelToTargetback to summary
protected boolean createTunnelToTarget(final HttpRoute route, final HttpContext context) throws 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.

Parameters
route:HttpRoute

the route to establish

context:HttpContext

the context for request execution

Returns:boolean

true if the tunnelled route is secure, false otherwise. The implementation here always returns false, but derived classes may override.

Exceptions
HttpException:
in case of a problem
IOException:
in case of an IO problem
determineRouteback to summary
protected HttpRoute determineRoute(final HttpHost targetHost, final HttpRequest request, final HttpContext context) throws HttpException

Determines the route for a request. Called by execute to determine the route for either the original or a followup request.

Parameters
targetHost:HttpHost

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:HttpRequest

the request to execute

context:HttpContext

the context to use for the execution, never null

Returns:HttpRoute

the route the request should take

Exceptions
HttpException:
in case of a problem
establishRouteback to summary
protected void establishRoute(final HttpRoute route, final HttpContext context) throws HttpException, IOException

Establishes the target route.

Parameters
route:HttpRoute

the route to establish

context:HttpContext

the context for the request execution

Exceptions
HttpException:
in case of a problem
IOException:
in case of an IO problem
executeback to summary
public HttpResponse execute(final HttpHost targetHost, final HttpRequest request, final HttpContext context) throws HttpException, IOException

Implements org.apache.http.client.RequestDirector.execute.

Doc from org.apache.http.client.RequestDirector.execute.

Executes a request.

Note

For the time being, a new director is instantiated for each request. This is the same behavior as for HttpMethodDirector in HttpClient 3.

Parameters
targetHost:HttpHost

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:HttpRequest

the request to execute

context:HttpContext

the context for executing the request

Returns:HttpResponse

the final response to the request. This is never an intermediate response with status code 1xx.

Annotations
@Override
Exceptions
HttpException:
in case of a problem
IOException:
in case of an IO problem or if the connection was aborted
handleResponseback to summary
protected RoutedRequest handleResponse(final RoutedRequest roureq, final HttpResponse response, final HttpContext context) throws HttpException, IOException

Deprecated

as a consequence of RoutedRequest being deprecated. See corresponding docs for further information.

Analyzes a response to check need for a followup.

Parameters
roureq:RoutedRequest

the request and route.

response:HttpResponse

the response to analayze

context:HttpContext

the context used for the current request execution

Returns:RoutedRequest

the followup request and route if there is a followup, or null if the response should be returned as is

Exceptions
HttpException:
in case of a problem
IOException:
in case of an IO problem
releaseConnectionback to summary
protected void releaseConnection()

Returns the connection back to the connection manager and prepares for retrieving a new connection during the next request.

rewriteRequestURIback to summary
protected void rewriteRequestURI(final RequestWrapper request, final HttpRoute route) throws ProtocolException

Deprecated

as a consequence of RequestWrapper being deprecated. See corresponding docs for further information.

tryConnectback to summary
private void tryConnect(final RoutedRequest req, final HttpContext context) throws HttpException, IOException

Deprecated

as a consequence of RoutedRequest being deprecated. See corresponding docs for further information.

Establish connection either directly or through a tunnel and retry in case of a recoverable I/O failure

tryExecuteback to summary
private HttpResponse tryExecute(final RoutedRequest req, final HttpContext context) throws HttpException, IOException

Deprecated

as a consequence of RoutedRequest being deprecated. See corresponding docs for further information.

Execute request and retry in case of a recoverable I/O failure

wrapRequestback to summary
private RequestWrapper wrapRequest(final HttpRequest request) throws ProtocolException

Deprecated

as a consequence of RequestWrapper being deprecated. See corresponding docs for further information.