|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.http.impl.client.AbstractHttpClient
@ThreadSafe public abstract class AbstractHttpClient
Base class for 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()
!
Constructor Summary | |
---|---|
protected |
AbstractHttpClient(ClientConnectionManager conman,
HttpParams params)
Creates a new HTTP client. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AbstractHttpClient(ClientConnectionManager conman, HttpParams params)
conman
- the connection managerparams
- the parametersMethod Detail |
---|
protected 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
getParams
in interface HttpClient
public void setParams(HttpParams params)
params
- the new default parameterspublic final ClientConnectionManager getConnectionManager()
HttpClient
getConnectionManager
in interface 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)
public final HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException
HttpClient
execute
in interface HttpClient
request
- the request to execute
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol errorpublic final HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException
execute(target, request, context)
.
The target is determined from the URI of the request.
execute
in interface HttpClient
request
- the request to executecontext
- the request-specific execution context,
or null
to use a default context
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol errorpublic final HttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolException
HttpClient
execute
in interface HttpClient
target
- the target host for the request.
Implementations may accept null
if they can still determine a route, for example
to a default target or by inspecting the request.request
- the request to execute
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol errorpublic final HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException
HttpClient
execute
in interface HttpClient
target
- the target host for the request.
Implementations may accept null
if they can still determine a route, for example
to a default target or by inspecting the request.request
- the request to executecontext
- the context to use for the execution, or
null
to use the default context
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol error@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.
execute(HttpHost,HttpRequest,HttpContext)
to obtain the parameters for the
DefaultRequestDirector
.
req
- the request that will be executed
public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException
ResponseHandler
s from having to manage
resource deallocation internally.
execute
in interface HttpClient
request
- the request to executeresponseHandler
- the response handler
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol errorpublic <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException, ClientProtocolException
ResponseHandler
s from having to manage
resource deallocation internally.
execute
in interface HttpClient
request
- the request to executeresponseHandler
- the response handlercontext
- the context to use for the execution, or
null
to use the default context
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol errorpublic <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException
ResponseHandler
s from having to manage
resource deallocation internally.
execute
in interface HttpClient
target
- the target host for the request.
Implementations may accept null
if they can still determine a route, for example
to a default target or by inspecting the request.request
- the request to executeresponseHandler
- the response handler
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol errorpublic <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException, ClientProtocolException
ResponseHandler
s from having to manage
resource deallocation internally.
execute
in interface HttpClient
target
- the target host for the request.
Implementations may accept null
if they can still determine a route, for example
to a default target or by inspecting the request.request
- the request to executeresponseHandler
- the response handlercontext
- the context to use for the execution, or
null
to use the default context
IOException
- in case of a problem or the connection was aborted
ClientProtocolException
- in case of an http protocol error
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |