HttpClientBuilder
.@ThreadSafe @Deprecated public abstract class AbstractHttpClient extends CloseableHttpClient
HttpClient
implementations.
This class acts as a facade to a number of special purpose handler or
strategy implementations responsible for handling of a particular aspect
of the HTTP protocol such as redirect or authentication handling or
making decision about connection persistence and keep alive duration.
This enables the users to selectively replace default implementation
of those aspects with custom, application specific ones. This class
also provides factory methods to instantiate those objects:
HttpRequestExecutor
createRequestExecutor()
must be
implemented by concrete super classes to instantiate this object.
BasicHttpProcessor
createHttpProcessor()
must be
implemented by concrete super classes to instantiate this object.
HttpRequestRetryHandler
createHttpRequestRetryHandler()
must be
implemented by concrete super classes to instantiate this object.
ClientConnectionManager
ConnectionReuseStrategy
createConnectionReuseStrategy()
must be
implemented by concrete super classes to instantiate this object.
ConnectionKeepAliveStrategy
createConnectionKeepAliveStrategy()
must be
implemented by concrete super classes to instantiate this object.
CookieSpecRegistry
createCookieSpecRegistry()
must be implemented by concrete
super classes to instantiate this object.
CookieStore
createCookieStore()
must be implemented by
concrete super classes to instantiate this object.
AuthSchemeRegistry
createAuthSchemeRegistry()
must be implemented by concrete
super classes to instantiate this object.
CredentialsProvider
createCredentialsProvider()
must be implemented by concrete super classes to instantiate
this object.
AuthenticationStrategy
createTargetAuthenticationStrategy()
must be implemented
by concrete super classes to instantiate this object.
AuthenticationStrategy
createProxyAuthenticationStrategy()
must be implemented
by concrete super classes to instantiate this object.
HttpRoutePlanner
createHttpRoutePlanner()
must be implemented
by concrete super classes to instantiate this object.
RedirectStrategy
UserTokenHandler
createUserTokenHandler()
must be implemented by
concrete super classes to instantiate this object.
This class also maintains a list of protocol interceptors intended
for processing outgoing requests and incoming responses and provides
methods for managing those interceptors. New protocol interceptors can be
introduced to the protocol processor chain or removed from it if needed.
Internally protocol interceptors are stored in a simple
ArrayList
. They are executed in the same natural order
as they are added to the list.
AbstractHttpClient is thread safe. It is recommended that the same
instance of this class is reused for multiple request executions.
When an instance of DefaultHttpClient is no longer needed and is about
to go out of scope the connection manager associated with it must be
shut down by calling ClientConnectionManager.shutdown()
!
Modifier | Constructor and Description |
---|---|
protected |
AbstractHttpClient(ClientConnectionManager conman,
HttpParams params)
Deprecated.
Creates a new HTTP client.
|
protected AbstractHttpClient(ClientConnectionManager conman, HttpParams params)
conman
- the connection managerparams
- the parametersprotected abstract HttpParams createHttpParams()
protected abstract BasicHttpProcessor createHttpProcessor()
protected HttpContext createHttpContext()
protected ClientConnectionManager createClientConnectionManager()
protected AuthSchemeRegistry createAuthSchemeRegistry()
protected CookieSpecRegistry createCookieSpecRegistry()
protected HttpRequestExecutor createRequestExecutor()
protected ConnectionReuseStrategy createConnectionReuseStrategy()
protected ConnectionKeepAliveStrategy createConnectionKeepAliveStrategy()
protected HttpRequestRetryHandler createHttpRequestRetryHandler()
@Deprecated protected RedirectHandler createRedirectHandler()
protected AuthenticationStrategy createTargetAuthenticationStrategy()
@Deprecated protected AuthenticationHandler createTargetAuthenticationHandler()
protected AuthenticationStrategy createProxyAuthenticationStrategy()
@Deprecated protected AuthenticationHandler createProxyAuthenticationHandler()
protected CookieStore createCookieStore()
protected CredentialsProvider createCredentialsProvider()
protected HttpRoutePlanner createHttpRoutePlanner()
protected UserTokenHandler createUserTokenHandler()
public final HttpParams getParams()
HttpClient
public void setParams(HttpParams params)
params
- the new default parameterspublic final ClientConnectionManager getConnectionManager()
HttpClient
public final HttpRequestExecutor getRequestExecutor()
public final AuthSchemeRegistry getAuthSchemes()
public void setAuthSchemes(AuthSchemeRegistry registry)
public final ConnectionBackoffStrategy getConnectionBackoffStrategy()
public void setConnectionBackoffStrategy(ConnectionBackoffStrategy strategy)
public final CookieSpecRegistry getCookieSpecs()
public final BackoffManager getBackoffManager()
public void setBackoffManager(BackoffManager manager)
public void setCookieSpecs(CookieSpecRegistry registry)
public final ConnectionReuseStrategy getConnectionReuseStrategy()
public void setReuseStrategy(ConnectionReuseStrategy strategy)
public final ConnectionKeepAliveStrategy getConnectionKeepAliveStrategy()
public void setKeepAliveStrategy(ConnectionKeepAliveStrategy strategy)
public final HttpRequestRetryHandler getHttpRequestRetryHandler()
public void setHttpRequestRetryHandler(HttpRequestRetryHandler handler)
@Deprecated public final RedirectHandler getRedirectHandler()
@Deprecated public void setRedirectHandler(RedirectHandler handler)
public final RedirectStrategy getRedirectStrategy()
public void setRedirectStrategy(RedirectStrategy strategy)
@Deprecated public final AuthenticationHandler getTargetAuthenticationHandler()
@Deprecated public void setTargetAuthenticationHandler(AuthenticationHandler handler)
public final AuthenticationStrategy getTargetAuthenticationStrategy()
public void setTargetAuthenticationStrategy(AuthenticationStrategy strategy)
@Deprecated public final AuthenticationHandler getProxyAuthenticationHandler()
@Deprecated public void setProxyAuthenticationHandler(AuthenticationHandler handler)
public final AuthenticationStrategy getProxyAuthenticationStrategy()
public void setProxyAuthenticationStrategy(AuthenticationStrategy strategy)
public final CookieStore getCookieStore()
public void setCookieStore(CookieStore cookieStore)
public final CredentialsProvider getCredentialsProvider()
public void setCredentialsProvider(CredentialsProvider credsProvider)
public final HttpRoutePlanner getRoutePlanner()
public void setRoutePlanner(HttpRoutePlanner routePlanner)
public final UserTokenHandler getUserTokenHandler()
public void setUserTokenHandler(UserTokenHandler handler)
protected final BasicHttpProcessor getHttpProcessor()
public int getResponseInterceptorCount()
public HttpResponseInterceptor getResponseInterceptor(int index)
public HttpRequestInterceptor getRequestInterceptor(int index)
public int getRequestInterceptorCount()
public void addResponseInterceptor(HttpResponseInterceptor itcp)
public void addResponseInterceptor(HttpResponseInterceptor itcp, int index)
public void clearResponseInterceptors()
public void removeResponseInterceptorByClass(Class<? extends HttpResponseInterceptor> clazz)
public void addRequestInterceptor(HttpRequestInterceptor itcp)
public void addRequestInterceptor(HttpRequestInterceptor itcp, int index)
public void clearRequestInterceptors()
public void removeRequestInterceptorByClass(Class<? extends HttpRequestInterceptor> clazz)
protected final CloseableHttpResponse doExecute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException
doExecute
in class CloseableHttpClient
IOException
ClientProtocolException
@Deprecated protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params)
@Deprecated protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectStrategy redirectStrategy, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params)
protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectStrategy redirectStrategy, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler, HttpParams params)
protected HttpParams determineParams(HttpRequest req)
ClientParamsStack
from the request parameters
and the client parameters.
CloseableHttpClient.execute(HttpHost,HttpRequest,HttpContext)
to obtain the parameters for the
DefaultRequestDirector
.req
- the request that will be executedpublic void close()
Copyright © 1999–2013 The Apache Software Foundation. All rights reserved.