Class AbstractHttpClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HttpClient
- Direct Known Subclasses:
DefaultHttpClient
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. ThecreateRequestExecutor()
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. ThecreateHttpProcessor()
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. ThecreateHttpRequestRetryHandler()
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. ThecreateConnectionReuseStrategy()
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. ThecreateConnectionKeepAliveStrategy()
must be implemented by concrete super classes to instantiate this object.CookieSpecRegistry
object used to maintain a list of supported cookie specifications. ThecreateCookieSpecRegistry()
must be implemented by concrete super classes to instantiate this object.CookieStore
object used to maintain a collection of cookies. ThecreateCookieStore()
must be implemented by concrete super classes to instantiate this object.AuthSchemeRegistry
object used to maintain a list of supported authentication schemes. ThecreateAuthSchemeRegistry()
must be implemented by concrete super classes to instantiate this object.CredentialsProvider
object used to maintain a collection user credentials. ThecreateCredentialsProvider()
must be implemented by concrete super classes to instantiate this object.AuthenticationStrategy
object used to authenticate against the target host. ThecreateTargetAuthenticationStrategy()
must be implemented by concrete super classes to instantiate this object.AuthenticationStrategy
object used to authenticate against the proxy host. ThecreateProxyAuthenticationStrategy()
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. ThecreateHttpRoutePlanner()
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. ThecreateUserTokenHandler()
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()
!
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.void
addRequestInterceptor
(HttpRequestInterceptor itcp, int index) Deprecated.void
Deprecated.void
addResponseInterceptor
(HttpResponseInterceptor itcp, int index) Deprecated.void
Deprecated.void
Deprecated.void
close()
Deprecated.final AuthSchemeRegistry
Deprecated.final BackoffManager
Deprecated.Deprecated.Deprecated.final ClientConnectionManager
Deprecated.Obtains the connection manager used by this client.final ConnectionReuseStrategy
Deprecated.final CookieSpecRegistry
Deprecated.final CookieStore
Deprecated.final CredentialsProvider
Deprecated.final HttpRequestRetryHandler
Deprecated.final HttpParams
Deprecated.Obtains the parameters for this client.final AuthenticationHandler
Deprecated.(4.2) do not usefinal AuthenticationStrategy
Deprecated.final RedirectHandler
Deprecated.(4.1) do not usefinal RedirectStrategy
Deprecated.final HttpRequestExecutor
Deprecated.getRequestInterceptor
(int index) Deprecated.int
Deprecated.getResponseInterceptor
(int index) Deprecated.int
Deprecated.final HttpRoutePlanner
Deprecated.final AuthenticationHandler
Deprecated.(4.2) do not usefinal AuthenticationStrategy
Deprecated.final UserTokenHandler
Deprecated.void
removeRequestInterceptorByClass
(Class<? extends HttpRequestInterceptor> clazz) Deprecated.void
removeResponseInterceptorByClass
(Class<? extends HttpResponseInterceptor> clazz) Deprecated.void
setAuthSchemes
(AuthSchemeRegistry registry) Deprecated.void
setBackoffManager
(BackoffManager manager) Deprecated.void
Deprecated.void
setCookieSpecs
(CookieSpecRegistry registry) Deprecated.void
setCookieStore
(CookieStore cookieStore) Deprecated.void
setCredentialsProvider
(CredentialsProvider credsProvider) Deprecated.void
Deprecated.void
Deprecated.void
setParams
(HttpParams params) Deprecated.Replaces the parameters.void
Deprecated.(4.2) do not usevoid
Deprecated.void
setRedirectHandler
(RedirectHandler handler) Deprecated.(4.1) do not usevoid
setRedirectStrategy
(RedirectStrategy strategy) Deprecated.void
setReuseStrategy
(ConnectionReuseStrategy strategy) Deprecated.void
setRoutePlanner
(HttpRoutePlanner routePlanner) Deprecated.void
Deprecated.(4.2) do not usevoid
Deprecated.void
setUserTokenHandler
(UserTokenHandler handler) Deprecated.
-
Method Details
-
getParams
Deprecated.Description copied from interface:HttpClient
Obtains the parameters for this client. These parameters will become defaults for all requests being executed with this client, and for the parameters of dependent objects in this client.- Returns:
- the default parameters
-
setParams
Deprecated.Replaces the parameters. The implementation here does not update parameters of dependent objects.- Parameters:
params
- the new default parameters
-
getConnectionManager
Deprecated.Description copied from interface:HttpClient
Obtains the connection manager used by this client.- Returns:
- the connection manager
-
getRequestExecutor
Deprecated. -
getAuthSchemes
Deprecated. -
setAuthSchemes
Deprecated. -
getConnectionBackoffStrategy
Deprecated. -
setConnectionBackoffStrategy
Deprecated. -
getCookieSpecs
Deprecated. -
getBackoffManager
Deprecated. -
setBackoffManager
Deprecated. -
setCookieSpecs
Deprecated. -
getConnectionReuseStrategy
Deprecated. -
setReuseStrategy
Deprecated. -
getConnectionKeepAliveStrategy
Deprecated. -
setKeepAliveStrategy
Deprecated. -
getHttpRequestRetryHandler
Deprecated. -
setHttpRequestRetryHandler
Deprecated. -
getRedirectHandler
Deprecated.(4.1) do not use -
setRedirectHandler
Deprecated.(4.1) do not use -
getRedirectStrategy
Deprecated.- Since:
- 4.1
-
setRedirectStrategy
Deprecated.- Since:
- 4.1
-
getTargetAuthenticationHandler
Deprecated.(4.2) do not use -
setTargetAuthenticationHandler
Deprecated.(4.2) do not use -
getTargetAuthenticationStrategy
Deprecated.- Since:
- 4.2
-
setTargetAuthenticationStrategy
Deprecated.- Since:
- 4.2
-
getProxyAuthenticationHandler
Deprecated.(4.2) do not use -
setProxyAuthenticationHandler
Deprecated.(4.2) do not use -
getProxyAuthenticationStrategy
Deprecated.- Since:
- 4.2
-
setProxyAuthenticationStrategy
Deprecated.- Since:
- 4.2
-
getCookieStore
Deprecated. -
setCookieStore
Deprecated. -
getCredentialsProvider
Deprecated. -
setCredentialsProvider
Deprecated. -
getRoutePlanner
Deprecated. -
setRoutePlanner
Deprecated. -
getUserTokenHandler
Deprecated. -
setUserTokenHandler
Deprecated. -
getResponseInterceptorCount
public int getResponseInterceptorCount()Deprecated. -
getResponseInterceptor
Deprecated. -
getRequestInterceptor
Deprecated. -
getRequestInterceptorCount
public int getRequestInterceptorCount()Deprecated. -
addResponseInterceptor
Deprecated. -
addResponseInterceptor
Deprecated. -
clearResponseInterceptors
public void clearResponseInterceptors()Deprecated. -
removeResponseInterceptorByClass
Deprecated. -
addRequestInterceptor
Deprecated. -
addRequestInterceptor
Deprecated. -
clearRequestInterceptors
public void clearRequestInterceptors()Deprecated. -
removeRequestInterceptorByClass
Deprecated. -
close
public void close()Deprecated.
-
HttpClientBuilder
.