Fields Summary |
---|
private final Log | log |
private HttpParams | defaultParamsThe parameters. |
private HttpRequestExecutor | requestExecThe request executor. |
private ClientConnectionManager | connManagerThe connection manager. |
private ConnectionReuseStrategy | reuseStrategyThe connection re-use strategy. |
private ConnectionKeepAliveStrategy | keepAliveStrategyThe connection keep-alive strategy. |
private CookieSpecRegistry | supportedCookieSpecsThe cookie spec registry. |
private AuthSchemeRegistry | supportedAuthSchemesThe authentication scheme registry. |
private BasicHttpProcessor | httpProcessorThe HTTP processor. |
private HttpRequestRetryHandler | retryHandlerThe request retry handler. |
private RedirectHandler | redirectHandlerThe redirect handler. |
private AuthenticationHandler | targetAuthHandlerThe target authentication handler. |
private AuthenticationHandler | proxyAuthHandlerThe proxy authentication handler. |
private CookieStore | cookieStoreThe cookie store. |
private CredentialsProvider | credsProviderThe credentials provider. |
private HttpRoutePlanner | routePlannerThe route planner. |
private UserTokenHandler | userTokenHandlerThe user token handler. |
Methods Summary |
---|
public synchronized void | addRequestInterceptor(org.apache.http.HttpRequestInterceptor itcp)
getHttpProcessor().addInterceptor(itcp);
|
public synchronized void | addRequestInterceptor(org.apache.http.HttpRequestInterceptor itcp, int index)
getHttpProcessor().addInterceptor(itcp, index);
|
public synchronized void | addResponseInterceptor(org.apache.http.HttpResponseInterceptor itcp)
getHttpProcessor().addInterceptor(itcp);
|
public synchronized void | addResponseInterceptor(org.apache.http.HttpResponseInterceptor itcp, int index)
getHttpProcessor().addInterceptor(itcp, index);
|
public synchronized void | clearRequestInterceptors()
getHttpProcessor().clearRequestInterceptors();
|
public synchronized void | clearResponseInterceptors()
getHttpProcessor().clearResponseInterceptors();
|
protected abstract org.apache.http.auth.AuthSchemeRegistry | createAuthSchemeRegistry()
|
protected abstract org.apache.http.conn.ClientConnectionManager | createClientConnectionManager()
|
protected org.apache.http.client.RequestDirector | createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec, org.apache.http.conn.ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, org.apache.http.conn.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 stateHandler, org.apache.http.params.HttpParams params)
return new DefaultRequestDirector(
requestExec,
conman,
reustrat,
kastrat,
rouplan,
httpProcessor,
retryHandler,
redirectHandler,
targetAuthHandler,
proxyAuthHandler,
stateHandler,
params);
|
protected abstract org.apache.http.conn.ConnectionKeepAliveStrategy | createConnectionKeepAliveStrategy()
|
protected abstract org.apache.http.ConnectionReuseStrategy | createConnectionReuseStrategy()
|
protected abstract org.apache.http.cookie.CookieSpecRegistry | createCookieSpecRegistry()
|
protected abstract org.apache.http.client.CookieStore | createCookieStore()
|
protected abstract org.apache.http.client.CredentialsProvider | createCredentialsProvider()
|
protected abstract org.apache.http.protocol.HttpContext | createHttpContext()
|
protected abstract org.apache.http.params.HttpParams | createHttpParams()
|
protected abstract org.apache.http.protocol.BasicHttpProcessor | createHttpProcessor()
|
protected abstract org.apache.http.client.HttpRequestRetryHandler | createHttpRequestRetryHandler()
|
protected abstract org.apache.http.conn.routing.HttpRoutePlanner | createHttpRoutePlanner()
|
protected abstract org.apache.http.client.AuthenticationHandler | createProxyAuthenticationHandler()
|
protected abstract org.apache.http.client.RedirectHandler | createRedirectHandler()
|
protected abstract org.apache.http.protocol.HttpRequestExecutor | createRequestExecutor()
|
protected abstract org.apache.http.client.AuthenticationHandler | createTargetAuthenticationHandler()
|
protected abstract org.apache.http.client.UserTokenHandler | createUserTokenHandler()
|
protected org.apache.http.params.HttpParams | determineParams(org.apache.http.HttpRequest req)Obtains parameters for executing a request.
The default implementation in this class creates a new
{@link ClientParamsStack} from the request parameters
and the client parameters.
This method is called by the default implementation of
{@link #execute(HttpHost,HttpRequest,HttpContext)}
to obtain the parameters for the
{@link DefaultRequestDirector}.
return new ClientParamsStack
(null, getParams(), req.getParams(), null);
|
private org.apache.http.HttpHost | determineTarget(org.apache.http.client.methods.HttpUriRequest request)
// A null target may be acceptable if there is a default target.
// Otherwise, the null target is detected in the director.
HttpHost target = null;
URI requestURI = request.getURI();
if (requestURI.isAbsolute()) {
target = new HttpHost(
requestURI.getHost(),
requestURI.getPort(),
requestURI.getScheme());
}
return target;
|
public final org.apache.http.HttpResponse | execute(org.apache.http.client.methods.HttpUriRequest request)
return execute(request, (HttpContext) null);
|
public final org.apache.http.HttpResponse | execute(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.protocol.HttpContext context)Maps to {@link HttpClient#execute(HttpHost,HttpRequest,HttpContext)
execute(target, request, context)}.
The target is determined from the URI of the request.
if (request == null) {
throw new IllegalArgumentException
("Request must not be null.");
}
return execute(determineTarget(request), request, context);
|
public final org.apache.http.HttpResponse | execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
return execute(target, request, (HttpContext) null);
|
public final org.apache.http.HttpResponse | execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context)
if (request == null) {
throw new IllegalArgumentException
("Request must not be null.");
}
// a null target may be acceptable, this depends on the route planner
// a null context is acceptable, default context created below
HttpContext execContext = null;
RequestDirector director = null;
// Initialize the request execution context making copies of
// all shared objects that are potentially threading unsafe.
synchronized (this) {
HttpContext defaultContext = createHttpContext();
if (context == null) {
execContext = defaultContext;
} else {
execContext = new DefaultedHttpContext(context, defaultContext);
}
// Create a director for this request
director = createClientRequestDirector(
getRequestExecutor(),
getConnectionManager(),
getConnectionReuseStrategy(),
getConnectionKeepAliveStrategy(),
getRoutePlanner(),
getHttpProcessor().copy(),
getHttpRequestRetryHandler(),
getRedirectHandler(),
getTargetAuthenticationHandler(),
getProxyAuthenticationHandler(),
getUserTokenHandler(),
determineParams(request));
}
try {
return director.execute(target, request, execContext);
} catch(HttpException httpException) {
throw new ClientProtocolException(httpException);
}
|
public T | execute(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.client.ResponseHandler responseHandler)
return execute(request, responseHandler, null);
|
public T | execute(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.client.ResponseHandler responseHandler, org.apache.http.protocol.HttpContext context)
HttpHost target = determineTarget(request);
return execute(target, request, responseHandler, context);
|
public T | execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.client.ResponseHandler responseHandler)
return execute(target, request, responseHandler, null);
|
public T | execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.client.ResponseHandler responseHandler, org.apache.http.protocol.HttpContext context)
if (responseHandler == null) {
throw new IllegalArgumentException
("Response handler must not be null.");
}
HttpResponse response = execute(target, request, context);
T result;
try {
result = responseHandler.handleResponse(response);
} catch (Throwable t) {
HttpEntity entity = response.getEntity();
if (entity != null) {
try {
entity.consumeContent();
} catch (Throwable t2) {
// Log this exception. The original exception is more
// important and will be thrown to the caller.
this.log.warn("Error consuming content after an exception.", t2);
}
}
if (t instanceof Error) {
throw (Error) t;
}
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
if (t instanceof IOException) {
throw (IOException) t;
}
throw new UndeclaredThrowableException(t);
}
// Handling the response was successful. Ensure that the content has
// been fully consumed.
HttpEntity entity = response.getEntity();
if (entity != null) {
// Let this exception go to the caller.
entity.consumeContent();
}
return result;
|
public final synchronized org.apache.http.auth.AuthSchemeRegistry | getAuthSchemes()
if (supportedAuthSchemes == null) {
supportedAuthSchemes = createAuthSchemeRegistry();
}
return supportedAuthSchemes;
|
public final synchronized org.apache.http.conn.ConnectionKeepAliveStrategy | getConnectionKeepAliveStrategy()
if (keepAliveStrategy == null) {
keepAliveStrategy = createConnectionKeepAliveStrategy();
}
return keepAliveStrategy;
|
public final synchronized org.apache.http.conn.ClientConnectionManager | getConnectionManager()
if (connManager == null) {
connManager = createClientConnectionManager();
}
return connManager;
|
public final synchronized org.apache.http.ConnectionReuseStrategy | getConnectionReuseStrategy()
if (reuseStrategy == null) {
reuseStrategy = createConnectionReuseStrategy();
}
return reuseStrategy;
|
public final synchronized org.apache.http.cookie.CookieSpecRegistry | getCookieSpecs()
if (supportedCookieSpecs == null) {
supportedCookieSpecs = createCookieSpecRegistry();
}
return supportedCookieSpecs;
|
public final synchronized org.apache.http.client.CookieStore | getCookieStore()
if (cookieStore == null) {
cookieStore = createCookieStore();
}
return cookieStore;
|
public final synchronized org.apache.http.client.CredentialsProvider | getCredentialsProvider()
if (credsProvider == null) {
credsProvider = createCredentialsProvider();
}
return credsProvider;
|
protected final synchronized org.apache.http.protocol.BasicHttpProcessor | getHttpProcessor()
if (httpProcessor == null) {
httpProcessor = createHttpProcessor();
}
return httpProcessor;
|
public final synchronized org.apache.http.client.HttpRequestRetryHandler | getHttpRequestRetryHandler()
if (retryHandler == null) {
retryHandler = createHttpRequestRetryHandler();
}
return retryHandler;
|
public final synchronized org.apache.http.params.HttpParams | getParams()
if (defaultParams == null) {
defaultParams = createHttpParams();
}
return defaultParams;
|
public final synchronized org.apache.http.client.AuthenticationHandler | getProxyAuthenticationHandler()
if (proxyAuthHandler == null) {
proxyAuthHandler = createProxyAuthenticationHandler();
}
return proxyAuthHandler;
|
public final synchronized org.apache.http.client.RedirectHandler | getRedirectHandler()
if (redirectHandler == null) {
redirectHandler = createRedirectHandler();
}
return redirectHandler;
|
public final synchronized org.apache.http.protocol.HttpRequestExecutor | getRequestExecutor()
if (requestExec == null) {
requestExec = createRequestExecutor();
}
return requestExec;
|
public synchronized org.apache.http.HttpRequestInterceptor | getRequestInterceptor(int index)
return getHttpProcessor().getRequestInterceptor(index);
|
public synchronized int | getRequestInterceptorCount()
return getHttpProcessor().getRequestInterceptorCount();
|
public synchronized org.apache.http.HttpResponseInterceptor | getResponseInterceptor(int index)
return getHttpProcessor().getResponseInterceptor(index);
|
public synchronized int | getResponseInterceptorCount()
return getHttpProcessor().getResponseInterceptorCount();
|
public final synchronized org.apache.http.conn.routing.HttpRoutePlanner | getRoutePlanner()
if (this.routePlanner == null) {
this.routePlanner = createHttpRoutePlanner();
}
return this.routePlanner;
|
public final synchronized org.apache.http.client.AuthenticationHandler | getTargetAuthenticationHandler()
if (targetAuthHandler == null) {
targetAuthHandler = createTargetAuthenticationHandler();
}
return targetAuthHandler;
|
public final synchronized org.apache.http.client.UserTokenHandler | getUserTokenHandler()
if (this.userTokenHandler == null) {
this.userTokenHandler = createUserTokenHandler();
}
return this.userTokenHandler;
|
public void | removeRequestInterceptorByClass(java.lang.Class clazz)
getHttpProcessor().removeRequestInterceptorByClass(clazz);
|
public void | removeResponseInterceptorByClass(java.lang.Class clazz)
getHttpProcessor().removeResponseInterceptorByClass(clazz);
|
public synchronized void | setAuthSchemes(org.apache.http.auth.AuthSchemeRegistry authSchemeRegistry)
supportedAuthSchemes = authSchemeRegistry;
|
public synchronized void | setCookieSpecs(org.apache.http.cookie.CookieSpecRegistry cookieSpecRegistry)
supportedCookieSpecs = cookieSpecRegistry;
|
public synchronized void | setCookieStore(org.apache.http.client.CookieStore cookieStore)
this.cookieStore = cookieStore;
|
public synchronized void | setCredentialsProvider(org.apache.http.client.CredentialsProvider credsProvider)
this.credsProvider = credsProvider;
|
public synchronized void | setHttpRequestRetryHandler(org.apache.http.client.HttpRequestRetryHandler retryHandler)
this.retryHandler = retryHandler;
|
public synchronized void | setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
this.keepAliveStrategy = keepAliveStrategy;
|
public synchronized void | setParams(org.apache.http.params.HttpParams params)Replaces the parameters.
The implementation here does not update parameters of dependent objects.
defaultParams = params;
|
public synchronized void | setProxyAuthenticationHandler(org.apache.http.client.AuthenticationHandler proxyAuthHandler)
this.proxyAuthHandler = proxyAuthHandler;
|
public synchronized void | setRedirectHandler(org.apache.http.client.RedirectHandler redirectHandler)
this.redirectHandler = redirectHandler;
|
public synchronized void | setReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
this.reuseStrategy = reuseStrategy;
|
public synchronized void | setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
this.routePlanner = routePlanner;
|
public synchronized void | setTargetAuthenticationHandler(org.apache.http.client.AuthenticationHandler targetAuthHandler)
this.targetAuthHandler = targetAuthHandler;
|
public synchronized void | setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
this.userTokenHandler = userTokenHandler;
|