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(org.apache.http.conn.ClientConnectionManager conman,
org.apache.http.params.HttpParams params)
Deprecated.
Creates a new HTTP client.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRequestInterceptor(HttpRequestInterceptor itcp)
Deprecated.
|
void |
addRequestInterceptor(HttpRequestInterceptor itcp,
int index)
Deprecated.
|
void |
addResponseInterceptor(HttpResponseInterceptor itcp)
Deprecated.
|
void |
addResponseInterceptor(HttpResponseInterceptor itcp,
int index)
Deprecated.
|
void |
clearRequestInterceptors()
Deprecated.
|
void |
clearResponseInterceptors()
Deprecated.
|
void |
close()
Deprecated.
|
protected org.apache.http.auth.AuthSchemeRegistry |
createAuthSchemeRegistry()
Deprecated.
|
protected org.apache.http.conn.ClientConnectionManager |
createClientConnectionManager()
Deprecated.
|
protected org.apache.http.client.RequestDirector |
createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
org.apache.http.conn.ClientConnectionManager conman,
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 userTokenHandler,
org.apache.http.params.HttpParams params)
Deprecated.
(4.1) do not use
|
protected org.apache.http.client.RequestDirector |
createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
org.apache.http.conn.ClientConnectionManager conman,
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.RedirectStrategy redirectStrategy,
org.apache.http.client.AuthenticationHandler targetAuthHandler,
org.apache.http.client.AuthenticationHandler proxyAuthHandler,
org.apache.http.client.UserTokenHandler userTokenHandler,
org.apache.http.params.HttpParams params)
Deprecated.
(4.2) do not use
|
protected org.apache.http.client.RequestDirector |
createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
org.apache.http.conn.ClientConnectionManager conman,
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.RedirectStrategy redirectStrategy,
org.apache.http.client.AuthenticationStrategy targetAuthStrategy,
org.apache.http.client.AuthenticationStrategy proxyAuthStrategy,
org.apache.http.client.UserTokenHandler userTokenHandler,
org.apache.http.params.HttpParams params)
Deprecated.
|
protected org.apache.http.conn.ConnectionKeepAliveStrategy |
createConnectionKeepAliveStrategy()
Deprecated.
|
protected ConnectionReuseStrategy |
createConnectionReuseStrategy()
Deprecated.
|
protected CookieSpecRegistry |
createCookieSpecRegistry()
Deprecated.
|
protected org.apache.http.client.CookieStore |
createCookieStore()
Deprecated.
|
protected org.apache.http.client.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 org.apache.http.client.HttpRequestRetryHandler |
createHttpRequestRetryHandler()
Deprecated.
|
protected org.apache.http.conn.routing.HttpRoutePlanner |
createHttpRoutePlanner()
Deprecated.
|
protected org.apache.http.client.AuthenticationHandler |
createProxyAuthenticationHandler()
Deprecated.
(4.2) do not use
|
protected org.apache.http.client.AuthenticationStrategy |
createProxyAuthenticationStrategy()
Deprecated.
|
protected org.apache.http.client.RedirectHandler |
createRedirectHandler()
Deprecated.
(4.1) do not use
|
protected org.apache.http.protocol.HttpRequestExecutor |
createRequestExecutor()
Deprecated.
|
protected org.apache.http.client.AuthenticationHandler |
createTargetAuthenticationHandler()
Deprecated.
(4.2) do not use
|
protected org.apache.http.client.AuthenticationStrategy |
createTargetAuthenticationStrategy()
Deprecated.
|
protected org.apache.http.client.UserTokenHandler |
createUserTokenHandler()
Deprecated.
|
protected org.apache.http.params.HttpParams |
determineParams(HttpRequest req)
Deprecated.
Obtains parameters for executing a request.
|
protected CloseableHttpResponse |
doExecute(HttpHost target,
HttpRequest request,
org.apache.http.protocol.HttpContext context)
Deprecated.
|
org.apache.http.auth.AuthSchemeRegistry |
getAuthSchemes()
Deprecated.
|
org.apache.http.client.BackoffManager |
getBackoffManager()
Deprecated.
|
org.apache.http.client.ConnectionBackoffStrategy |
getConnectionBackoffStrategy()
Deprecated.
|
org.apache.http.conn.ConnectionKeepAliveStrategy |
getConnectionKeepAliveStrategy()
Deprecated.
|
org.apache.http.conn.ClientConnectionManager |
getConnectionManager()
Deprecated.
|
ConnectionReuseStrategy |
getConnectionReuseStrategy()
Deprecated.
|
CookieSpecRegistry |
getCookieSpecs()
Deprecated.
|
org.apache.http.client.CookieStore |
getCookieStore()
Deprecated.
|
org.apache.http.client.CredentialsProvider |
getCredentialsProvider()
Deprecated.
|
protected org.apache.http.protocol.BasicHttpProcessor |
getHttpProcessor()
Deprecated.
|
org.apache.http.client.HttpRequestRetryHandler |
getHttpRequestRetryHandler()
Deprecated.
|
org.apache.http.params.HttpParams |
getParams()
Deprecated.
|
org.apache.http.client.AuthenticationHandler |
getProxyAuthenticationHandler()
Deprecated.
(4.2) do not use
|
org.apache.http.client.AuthenticationStrategy |
getProxyAuthenticationStrategy()
Deprecated.
|
org.apache.http.client.RedirectHandler |
getRedirectHandler()
Deprecated.
(4.1) do not use
|
org.apache.http.client.RedirectStrategy |
getRedirectStrategy()
Deprecated.
|
org.apache.http.protocol.HttpRequestExecutor |
getRequestExecutor()
Deprecated.
|
HttpRequestInterceptor |
getRequestInterceptor(int index)
Deprecated.
|
int |
getRequestInterceptorCount()
Deprecated.
|
HttpResponseInterceptor |
getResponseInterceptor(int index)
Deprecated.
|
int |
getResponseInterceptorCount()
Deprecated.
|
org.apache.http.conn.routing.HttpRoutePlanner |
getRoutePlanner()
Deprecated.
|
org.apache.http.client.AuthenticationHandler |
getTargetAuthenticationHandler()
Deprecated.
(4.2) do not use
|
org.apache.http.client.AuthenticationStrategy |
getTargetAuthenticationStrategy()
Deprecated.
|
org.apache.http.client.UserTokenHandler |
getUserTokenHandler()
Deprecated.
|
void |
removeRequestInterceptorByClass(java.lang.Class<? extends HttpRequestInterceptor> clazz)
Deprecated.
|
void |
removeResponseInterceptorByClass(java.lang.Class<? extends HttpResponseInterceptor> clazz)
Deprecated.
|
void |
setAuthSchemes(org.apache.http.auth.AuthSchemeRegistry registry)
Deprecated.
|
void |
setBackoffManager(org.apache.http.client.BackoffManager manager)
Deprecated.
|
void |
setConnectionBackoffStrategy(org.apache.http.client.ConnectionBackoffStrategy strategy)
Deprecated.
|
void |
setCookieSpecs(CookieSpecRegistry registry)
Deprecated.
|
void |
setCookieStore(org.apache.http.client.CookieStore cookieStore)
Deprecated.
|
void |
setCredentialsProvider(org.apache.http.client.CredentialsProvider credsProvider)
Deprecated.
|
void |
setHttpRequestRetryHandler(org.apache.http.client.HttpRequestRetryHandler handler)
Deprecated.
|
void |
setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy strategy)
Deprecated.
|
void |
setParams(org.apache.http.params.HttpParams params)
Deprecated.
Replaces the parameters.
|
void |
setProxyAuthenticationHandler(org.apache.http.client.AuthenticationHandler handler)
Deprecated.
(4.2) do not use
|
void |
setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy strategy)
Deprecated.
|
void |
setRedirectHandler(org.apache.http.client.RedirectHandler handler)
Deprecated.
(4.1) do not use
|
void |
setRedirectStrategy(org.apache.http.client.RedirectStrategy strategy)
Deprecated.
|
void |
setReuseStrategy(ConnectionReuseStrategy strategy)
Deprecated.
|
void |
setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
Deprecated.
|
void |
setTargetAuthenticationHandler(org.apache.http.client.AuthenticationHandler handler)
Deprecated.
(4.2) do not use
|
void |
setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy strategy)
Deprecated.
|
void |
setUserTokenHandler(org.apache.http.client.UserTokenHandler handler)
Deprecated.
|
protected AbstractHttpClient(org.apache.http.conn.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 org.apache.http.conn.ClientConnectionManager createClientConnectionManager()
protected org.apache.http.auth.AuthSchemeRegistry createAuthSchemeRegistry()
protected CookieSpecRegistry createCookieSpecRegistry()
protected org.apache.http.protocol.HttpRequestExecutor createRequestExecutor()
protected ConnectionReuseStrategy createConnectionReuseStrategy()
protected org.apache.http.conn.ConnectionKeepAliveStrategy createConnectionKeepAliveStrategy()
protected org.apache.http.client.HttpRequestRetryHandler createHttpRequestRetryHandler()
@Deprecated protected org.apache.http.client.RedirectHandler createRedirectHandler()
protected org.apache.http.client.AuthenticationStrategy createTargetAuthenticationStrategy()
@Deprecated protected org.apache.http.client.AuthenticationHandler createTargetAuthenticationHandler()
protected org.apache.http.client.AuthenticationStrategy createProxyAuthenticationStrategy()
@Deprecated protected org.apache.http.client.AuthenticationHandler createProxyAuthenticationHandler()
protected org.apache.http.client.CookieStore createCookieStore()
protected org.apache.http.client.CredentialsProvider createCredentialsProvider()
protected org.apache.http.conn.routing.HttpRoutePlanner createHttpRoutePlanner()
protected org.apache.http.client.UserTokenHandler createUserTokenHandler()
public final org.apache.http.params.HttpParams getParams()
public void setParams(org.apache.http.params.HttpParams params)
params - the new default parameterspublic final org.apache.http.conn.ClientConnectionManager getConnectionManager()
public final org.apache.http.protocol.HttpRequestExecutor getRequestExecutor()
public final org.apache.http.auth.AuthSchemeRegistry getAuthSchemes()
public void setAuthSchemes(org.apache.http.auth.AuthSchemeRegistry registry)
public final org.apache.http.client.ConnectionBackoffStrategy getConnectionBackoffStrategy()
public void setConnectionBackoffStrategy(org.apache.http.client.ConnectionBackoffStrategy strategy)
public final CookieSpecRegistry getCookieSpecs()
public final org.apache.http.client.BackoffManager getBackoffManager()
public void setBackoffManager(org.apache.http.client.BackoffManager manager)
public void setCookieSpecs(CookieSpecRegistry registry)
public final ConnectionReuseStrategy getConnectionReuseStrategy()
public void setReuseStrategy(ConnectionReuseStrategy strategy)
public final org.apache.http.conn.ConnectionKeepAliveStrategy getConnectionKeepAliveStrategy()
public void setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy strategy)
public final org.apache.http.client.HttpRequestRetryHandler getHttpRequestRetryHandler()
public void setHttpRequestRetryHandler(org.apache.http.client.HttpRequestRetryHandler handler)
@Deprecated public final org.apache.http.client.RedirectHandler getRedirectHandler()
@Deprecated public void setRedirectHandler(org.apache.http.client.RedirectHandler handler)
public final org.apache.http.client.RedirectStrategy getRedirectStrategy()
public void setRedirectStrategy(org.apache.http.client.RedirectStrategy strategy)
@Deprecated public final org.apache.http.client.AuthenticationHandler getTargetAuthenticationHandler()
@Deprecated public void setTargetAuthenticationHandler(org.apache.http.client.AuthenticationHandler handler)
public final org.apache.http.client.AuthenticationStrategy getTargetAuthenticationStrategy()
public void setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy strategy)
@Deprecated public final org.apache.http.client.AuthenticationHandler getProxyAuthenticationHandler()
@Deprecated public void setProxyAuthenticationHandler(org.apache.http.client.AuthenticationHandler handler)
public final org.apache.http.client.AuthenticationStrategy getProxyAuthenticationStrategy()
public void setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy strategy)
public final org.apache.http.client.CookieStore getCookieStore()
public void setCookieStore(org.apache.http.client.CookieStore cookieStore)
public final org.apache.http.client.CredentialsProvider getCredentialsProvider()
public void setCredentialsProvider(org.apache.http.client.CredentialsProvider credsProvider)
public final org.apache.http.conn.routing.HttpRoutePlanner getRoutePlanner()
public void setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
public final org.apache.http.client.UserTokenHandler getUserTokenHandler()
public void setUserTokenHandler(org.apache.http.client.UserTokenHandler handler)
protected final org.apache.http.protocol.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(java.lang.Class<? extends HttpResponseInterceptor> clazz)
public void addRequestInterceptor(HttpRequestInterceptor itcp)
public void addRequestInterceptor(HttpRequestInterceptor itcp, int index)
public void clearRequestInterceptors()
public void removeRequestInterceptorByClass(java.lang.Class<? extends HttpRequestInterceptor> clazz)
protected final CloseableHttpResponse doExecute(HttpHost target, HttpRequest request, org.apache.http.protocol.HttpContext context) throws java.io.IOException, org.apache.http.client.ClientProtocolException
doExecute in class CloseableHttpClientjava.io.IOExceptionorg.apache.http.client.ClientProtocolException@Deprecated
protected org.apache.http.client.RequestDirector createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
org.apache.http.conn.ClientConnectionManager conman,
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 userTokenHandler,
org.apache.http.params.HttpParams params)
@Deprecated
protected org.apache.http.client.RequestDirector createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
org.apache.http.conn.ClientConnectionManager conman,
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.RedirectStrategy redirectStrategy,
org.apache.http.client.AuthenticationHandler targetAuthHandler,
org.apache.http.client.AuthenticationHandler proxyAuthHandler,
org.apache.http.client.UserTokenHandler userTokenHandler,
org.apache.http.params.HttpParams params)
protected org.apache.http.client.RequestDirector createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec,
org.apache.http.conn.ClientConnectionManager conman,
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.RedirectStrategy redirectStrategy,
org.apache.http.client.AuthenticationStrategy targetAuthStrategy,
org.apache.http.client.AuthenticationStrategy proxyAuthStrategy,
org.apache.http.client.UserTokenHandler userTokenHandler,
org.apache.http.params.HttpParams params)
protected org.apache.http.params.HttpParams determineParams(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()