public class

DefaultRequestDirector

extends Object
implements RequestDirector
java.lang.Object
   ↳ org.apache.http.impl.client.DefaultRequestDirector

Summary

Fields
protected final ClientConnectionManager connManager The connection manager.
protected final HttpProcessor httpProcessor The HTTP protocol processor.
protected final ConnectionKeepAliveStrategy keepAliveStrategy The keep-alive duration strategy.
protected ManagedClientConnection managedConn The currently allocated connection.
protected final HttpParams params The HTTP parameters.
protected final AuthenticationHandler proxyAuthHandler The proxy authentication handler.
protected final AuthState proxyAuthState
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 targetAuthState
protected final UserTokenHandler userTokenHandler The user token handler.
Public Constructors
DefaultRequestDirector(HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params)
DefaultRequestDirector(Log log, HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectStrategy redirectStrategy, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params)
Public Methods
HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
Executes a request.
Protected Methods
HttpRequest createConnectRequest(HttpRoute route, HttpContext context)
Creates the CONNECT request for tunnelling.
boolean createTunnelToProxy(HttpRoute route, int hop, HttpContext context)
Creates a tunnel to an intermediate proxy.
boolean createTunnelToTarget(HttpRoute route, HttpContext context)
Creates a tunnel to the target server.
HttpRoute determineRoute(HttpHost target, HttpRequest request, HttpContext context)
Determines the route for a request.
void establishRoute(HttpRoute route, HttpContext context)
Establishes the target route.
RoutedRequest handleResponse(RoutedRequest roureq, HttpResponse response, HttpContext context)
Analyzes a response to check need for a followup.
void releaseConnection()
Returns the connection back to the connection manager and prepares for retrieving a new connection during the next request.
void rewriteRequestURI(RequestWrapper request, HttpRoute route)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.client.RequestDirector

Fields

protected final ClientConnectionManager connManager

Also: HttpClient

The connection manager.

protected final HttpProcessor httpProcessor

Also: HttpClient

The HTTP protocol processor.

protected final ConnectionKeepAliveStrategy keepAliveStrategy

Also: HttpClient

The keep-alive duration strategy.

protected ManagedClientConnection managedConn

Also: HttpClient

The currently allocated connection.

protected final HttpParams params

Also: HttpClient

The HTTP parameters.

protected final AuthenticationHandler proxyAuthHandler

Also: HttpClient

The proxy authentication handler.

protected final AuthState proxyAuthState

Also: HttpClient

protected final RedirectHandler redirectHandler

Also: HttpClient

The redirect handler.

protected final RedirectStrategy redirectStrategy

Also: HttpClient

The redirect strategy.

protected final HttpRequestExecutor requestExec

Also: HttpClient

The request executor.

protected final HttpRequestRetryHandler retryHandler

Also: HttpClient

The request retry handler.

protected final ConnectionReuseStrategy reuseStrategy

Also: HttpClient

The connection re-use strategy.

protected final HttpRoutePlanner routePlanner

Also: HttpClient

The route planner.

protected final AuthenticationHandler targetAuthHandler

Also: HttpClient

The target authentication handler.

protected final AuthState targetAuthState

Also: HttpClient

protected final UserTokenHandler userTokenHandler

Also: HttpClient

The user token handler.

Public Constructors

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

Also: HttpClient

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

Also: HttpClient

Public Methods

public HttpResponse execute (HttpHost target, HttpRequest request, HttpContext context)

Also: HttpClient

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
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 execute
context the context for executing the request
Returns
  • the final response to the request. This is never an intermediate response with status code 1xx.

Protected Methods

protected HttpRequest createConnectRequest (HttpRoute route, HttpContext context)

Also: HttpClient

Creates the CONNECT request for tunnelling. Called by createTunnelToTarget.

Parameters
route the route to establish
context the context for request execution
Returns
  • the CONNECT request for tunnelling

protected boolean createTunnelToProxy (HttpRoute route, int hop, HttpContext context)

Also: HttpClient

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

Parameters
route the route to establish
hop the hop in the route to establish now. route.getHopTarget(hop) will return the proxy to tunnel to.
context the context for request execution
Returns
  • true if the partially tunnelled connection is secure, false otherwise.
Throws
HttpException in case of a problem
IOException in case of an IO problem

protected boolean createTunnelToTarget (HttpRoute route, HttpContext context)

Also: HttpClient

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 the route to establish
context the context for request execution
Returns
  • true if the tunnelled route is secure, false otherwise. The implementation here always returns false, but derived classes may override.
Throws
HttpException in case of a problem
IOException in case of an IO problem

protected HttpRoute determineRoute (HttpHost target, HttpRequest request, HttpContext context)

Also: HttpClient

Determines the route for a request. Called by execute(HttpHost, HttpRequest, HttpContext) to determine the route for either the original or a followup request.

Parameters
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 execute
context the context to use for the execution, never null
Returns
  • the route the request should take
Throws
HttpException in case of a problem

protected void establishRoute (HttpRoute route, HttpContext context)

Also: HttpClient

Establishes the target route.

Parameters
route the route to establish
context the context for the request execution
Throws
HttpException in case of a problem
IOException in case of an IO problem

protected RoutedRequest handleResponse (RoutedRequest roureq, HttpResponse response, HttpContext context)

Also: HttpClient

Analyzes a response to check need for a followup.

Parameters
roureq the request and route.
response the response to analayze
context the context used for the current request execution
Returns
  • the followup request and route if there is a followup, or null if the response should be returned as is
Throws
HttpException in case of a problem
IOException in case of an IO problem

protected void releaseConnection ()

Also: HttpClient

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

protected void rewriteRequestURI (RequestWrapper request, HttpRoute route)

Also: HttpClient