HttpClientBuilder
.@Contract(threading=SAFE_CONDITIONAL) @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
object used to transmit messages
over HTTP connections. The createRequestExecutor()
must be
implemented by concrete super classes to instantiate this object.
BasicHttpProcessor
object to manage a list of protocol
interceptors and apply cross-cutting protocol logic to all incoming
and outgoing HTTP messages. The createHttpProcessor()
must be
implemented by concrete super classes to instantiate this object.
HttpRequestRetryHandler
object used to decide whether
or not a failed HTTP request is safe to retry automatically.
The createHttpRequestRetryHandler()
must be
implemented by concrete super classes to instantiate this object.
ClientConnectionManager
object used to manage
persistent HTTP connections.
ConnectionReuseStrategy
object used to decide whether
or not a HTTP connection can be kept alive and re-used for subsequent
HTTP requests. The createConnectionReuseStrategy()
must be
implemented by concrete super classes to instantiate this object.
ConnectionKeepAliveStrategy
object used to decide how
long a persistent HTTP connection can be kept alive.
The createConnectionKeepAliveStrategy()
must be
implemented by concrete super classes to instantiate this object.
CookieSpecRegistry
object used to maintain a list of
supported cookie specifications.
The createCookieSpecRegistry()
must be implemented by concrete
super classes to instantiate this object.
CookieStore
object used to maintain a collection of
cookies. The createCookieStore()
must be implemented by
concrete super classes to instantiate this object.
AuthSchemeRegistry
object used to maintain a list of
supported authentication schemes.
The createAuthSchemeRegistry()
must be implemented by concrete
super classes to instantiate this object.
CredentialsProvider
object used to maintain
a collection user credentials. The createCredentialsProvider()
must be implemented by concrete super classes to instantiate
this object.
AuthenticationStrategy
object used to authenticate
against the target host.
The createTargetAuthenticationStrategy()
must be implemented
by concrete super classes to instantiate this object.
AuthenticationStrategy
object used to authenticate
against the proxy host.
The createProxyAuthenticationStrategy()
must be implemented
by concrete super classes to instantiate this object.
HttpRoutePlanner
object used to calculate a route
for establishing a connection to the target host. The route
may involve multiple intermediate hops.
The createHttpRoutePlanner()
must be implemented
by concrete super classes to instantiate this object.
RedirectStrategy
object used to determine if an HTTP
request should be redirected to a new location in response to an HTTP
response received from the target server.
UserTokenHandler
object used to determine if the
execution context is user identity specific.
The 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,
org.apache.http.params.HttpParams params)
Deprecated.
Creates a new HTTP client.
|
Modifier and Type | Method and Description |
---|---|
void |
addRequestInterceptor(org.apache.http.HttpRequestInterceptor itcp)
Deprecated.
|
void |
addRequestInterceptor(org.apache.http.HttpRequestInterceptor itcp,
int index)
Deprecated.
|
void |
addResponseInterceptor(org.apache.http.HttpResponseInterceptor itcp)
Deprecated.
|
void |
addResponseInterceptor(org.apache.http.HttpResponseInterceptor itcp,
int index)
Deprecated.
|
void |
clearRequestInterceptors()
Deprecated.
|
void |
clearResponseInterceptors()
Deprecated.
|
void |
close()
Deprecated.
|
protected AuthSchemeRegistry |
createAuthSchemeRegistry()
Deprecated.
|
protected ClientConnectionManager |
createClientConnectionManager()
Deprecated.
|
protected RequestDirector |
createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
ClientConnectionManager conman,
org.apache.http.ConnectionReuseStrategy reustrat,
ConnectionKeepAliveStrategy kastrat,
HttpRoutePlanner rouplan,
org.apache.http.protocol.HttpProcessor httpProcessor,
HttpRequestRetryHandler retryHandler,
RedirectHandler redirectHandler,
AuthenticationHandler targetAuthHandler,
AuthenticationHandler proxyAuthHandler,
UserTokenHandler userTokenHandler,
org.apache.http.params.HttpParams params)
Deprecated.
(4.1) do not use
|
protected RequestDirector |
createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
ClientConnectionManager conman,
org.apache.http.ConnectionReuseStrategy reustrat,
ConnectionKeepAliveStrategy kastrat,
HttpRoutePlanner rouplan,
org.apache.http.protocol.HttpProcessor httpProcessor,
HttpRequestRetryHandler retryHandler,
RedirectStrategy redirectStrategy,
AuthenticationHandler targetAuthHandler,
AuthenticationHandler proxyAuthHandler,
UserTokenHandler userTokenHandler,
org.apache.http.params.HttpParams params)
Deprecated.
(4.2) do not use
|
protected RequestDirector |
createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
ClientConnectionManager conman,
org.apache.http.ConnectionReuseStrategy reustrat,
ConnectionKeepAliveStrategy kastrat,
HttpRoutePlanner rouplan,
org.apache.http.protocol.HttpProcessor httpProcessor,
HttpRequestRetryHandler retryHandler,
RedirectStrategy redirectStrategy,
AuthenticationStrategy targetAuthStrategy,
AuthenticationStrategy proxyAuthStrategy,
UserTokenHandler userTokenHandler,
org.apache.http.params.HttpParams params)
Deprecated.
|
protected ConnectionKeepAliveStrategy |
createConnectionKeepAliveStrategy()
Deprecated.
|
protected org.apache.http.ConnectionReuseStrategy |
createConnectionReuseStrategy()
Deprecated.
|
protected CookieSpecRegistry |
createCookieSpecRegistry()
Deprecated.
|
protected CookieStore |
createCookieStore()
Deprecated.
|
protected CredentialsProvider |
createCredentialsProvider()
Deprecated.
|
protected org.apache.http.protocol.HttpContext |
createHttpContext()
Deprecated.
|
protected abstract org.apache.http.params.HttpParams |
createHttpParams()
Deprecated.
|
protected abstract org.apache.http.protocol.BasicHttpProcessor |
createHttpProcessor()
Deprecated.
|
protected HttpRequestRetryHandler |
createHttpRequestRetryHandler()
Deprecated.
|
protected HttpRoutePlanner |
createHttpRoutePlanner()
Deprecated.
|
protected AuthenticationHandler |
createProxyAuthenticationHandler()
Deprecated.
(4.2) do not use
|
protected AuthenticationStrategy |
createProxyAuthenticationStrategy()
Deprecated.
|
protected RedirectHandler |
createRedirectHandler()
Deprecated.
(4.1) do not use
|
protected org.apache.http.protocol.HttpRequestExecutor |
createRequestExecutor()
Deprecated.
|
protected AuthenticationHandler |
createTargetAuthenticationHandler()
Deprecated.
(4.2) do not use
|
protected AuthenticationStrategy |
createTargetAuthenticationStrategy()
Deprecated.
|
protected UserTokenHandler |
createUserTokenHandler()
Deprecated.
|
protected org.apache.http.params.HttpParams |
determineParams(org.apache.http.HttpRequest req)
Deprecated.
Obtains parameters for executing a request.
|
protected CloseableHttpResponse |
doExecute(org.apache.http.HttpHost target,
org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context)
Deprecated.
|
AuthSchemeRegistry |
getAuthSchemes()
Deprecated.
|
BackoffManager |
getBackoffManager()
Deprecated.
|
ConnectionBackoffStrategy |
getConnectionBackoffStrategy()
Deprecated.
|
ConnectionKeepAliveStrategy |
getConnectionKeepAliveStrategy()
Deprecated.
|
ClientConnectionManager |
getConnectionManager()
Deprecated.
Obtains the connection manager used by this client.
|
org.apache.http.ConnectionReuseStrategy |
getConnectionReuseStrategy()
Deprecated.
|
CookieSpecRegistry |
getCookieSpecs()
Deprecated.
|
CookieStore |
getCookieStore()
Deprecated.
|
CredentialsProvider |
getCredentialsProvider()
Deprecated.
|
protected org.apache.http.protocol.BasicHttpProcessor |
getHttpProcessor()
Deprecated.
|
HttpRequestRetryHandler |
getHttpRequestRetryHandler()
Deprecated.
|
org.apache.http.params.HttpParams |
getParams()
Deprecated.
Obtains the parameters for this client.
|
AuthenticationHandler |
getProxyAuthenticationHandler()
Deprecated.
(4.2) do not use
|
AuthenticationStrategy |
getProxyAuthenticationStrategy()
Deprecated.
|
RedirectHandler |
getRedirectHandler()
Deprecated.
(4.1) do not use
|
RedirectStrategy |
getRedirectStrategy()
Deprecated.
|
org.apache.http.protocol.HttpRequestExecutor |
getRequestExecutor()
Deprecated.
|
org.apache.http.HttpRequestInterceptor |
getRequestInterceptor(int index)
Deprecated.
|
int |
getRequestInterceptorCount()
Deprecated.
|
org.apache.http.HttpResponseInterceptor |
getResponseInterceptor(int index)
Deprecated.
|
int |
getResponseInterceptorCount()
Deprecated.
|
HttpRoutePlanner |
getRoutePlanner()
Deprecated.
|
AuthenticationHandler |
getTargetAuthenticationHandler()
Deprecated.
(4.2) do not use
|
AuthenticationStrategy |
getTargetAuthenticationStrategy()
Deprecated.
|
UserTokenHandler |
getUserTokenHandler()
Deprecated.
|
void |
removeRequestInterceptorByClass(Class<? extends org.apache.http.HttpRequestInterceptor> clazz)
Deprecated.
|
void |
removeResponseInterceptorByClass(Class<? extends org.apache.http.HttpResponseInterceptor> clazz)
Deprecated.
|
void |
setAuthSchemes(AuthSchemeRegistry registry)
Deprecated.
|
void |
setBackoffManager(BackoffManager manager)
Deprecated.
|
void |
setConnectionBackoffStrategy(ConnectionBackoffStrategy strategy)
Deprecated.
|
void |
setCookieSpecs(CookieSpecRegistry registry)
Deprecated.
|
void |
setCookieStore(CookieStore cookieStore)
Deprecated.
|
void |
setCredentialsProvider(CredentialsProvider credsProvider)
Deprecated.
|
void |
setHttpRequestRetryHandler(HttpRequestRetryHandler handler)
Deprecated.
|
void |
setKeepAliveStrategy(ConnectionKeepAliveStrategy strategy)
Deprecated.
|
void |
setParams(org.apache.http.params.HttpParams params)
Deprecated.
Replaces the parameters.
|
void |
setProxyAuthenticationHandler(AuthenticationHandler handler)
Deprecated.
(4.2) do not use
|
void |
setProxyAuthenticationStrategy(AuthenticationStrategy strategy)
Deprecated.
|
void |
setRedirectHandler(RedirectHandler handler)
Deprecated.
(4.1) do not use
|
void |
setRedirectStrategy(RedirectStrategy strategy)
Deprecated.
|
void |
setReuseStrategy(org.apache.http.ConnectionReuseStrategy strategy)
Deprecated.
|
void |
setRoutePlanner(HttpRoutePlanner routePlanner)
Deprecated.
|
void |
setTargetAuthenticationHandler(AuthenticationHandler handler)
Deprecated.
(4.2) do not use
|
void |
setTargetAuthenticationStrategy(AuthenticationStrategy strategy)
Deprecated.
|
void |
setUserTokenHandler(UserTokenHandler handler)
Deprecated.
|
protected AbstractHttpClient(ClientConnectionManager conman, org.apache.http.params.HttpParams params)
conman
- the connection managerparams
- the parametersprotected abstract org.apache.http.params.HttpParams createHttpParams()
protected abstract org.apache.http.protocol.BasicHttpProcessor createHttpProcessor()
protected org.apache.http.protocol.HttpContext createHttpContext()
protected ClientConnectionManager createClientConnectionManager()
protected AuthSchemeRegistry createAuthSchemeRegistry()
protected CookieSpecRegistry createCookieSpecRegistry()
protected org.apache.http.protocol.HttpRequestExecutor createRequestExecutor()
protected org.apache.http.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 org.apache.http.params.HttpParams getParams()
HttpClient
public void setParams(org.apache.http.params.HttpParams params)
params
- the new default parameterspublic final ClientConnectionManager getConnectionManager()
HttpClient
public final org.apache.http.protocol.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 org.apache.http.ConnectionReuseStrategy getConnectionReuseStrategy()
public void setReuseStrategy(org.apache.http.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 org.apache.http.protocol.BasicHttpProcessor getHttpProcessor()
public int getResponseInterceptorCount()
public org.apache.http.HttpResponseInterceptor getResponseInterceptor(int index)
public org.apache.http.HttpRequestInterceptor getRequestInterceptor(int index)
public int getRequestInterceptorCount()
public void addResponseInterceptor(org.apache.http.HttpResponseInterceptor itcp)
public void addResponseInterceptor(org.apache.http.HttpResponseInterceptor itcp, int index)
public void clearResponseInterceptors()
public void removeResponseInterceptorByClass(Class<? extends org.apache.http.HttpResponseInterceptor> clazz)
public void addRequestInterceptor(org.apache.http.HttpRequestInterceptor itcp)
public void addRequestInterceptor(org.apache.http.HttpRequestInterceptor itcp, int index)
public void clearRequestInterceptors()
public void removeRequestInterceptorByClass(Class<? extends org.apache.http.HttpRequestInterceptor> clazz)
protected final CloseableHttpResponse doExecute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context) throws IOException, ClientProtocolException
doExecute
in class CloseableHttpClient
IOException
ClientProtocolException
@Deprecated protected RequestDirector createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec, ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, org.apache.http.protocol.HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, org.apache.http.params.HttpParams params)
@Deprecated protected RequestDirector createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec, ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, org.apache.http.protocol.HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectStrategy redirectStrategy, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, org.apache.http.params.HttpParams params)
protected RequestDirector createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec, ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, org.apache.http.protocol.HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectStrategy redirectStrategy, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler, org.apache.http.params.HttpParams params)
protected org.apache.http.params.HttpParams determineParams(org.apache.http.HttpRequest req)
ClientParamsStack
from the request parameters
and the client parameters.
This method is called by the default implementation of
CloseableHttpClient.execute(HttpHost,HttpRequest,HttpContext)
to obtain the parameters for the
DefaultRequestDirector
.
req
- the request that will be executedpublic void close()
Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.