Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public abstract class

AbstractHttpClient

extends Object
implements HttpClient
java.lang.Object
   ↳ org.apache.http.impl.client.AbstractHttpClient
Known Direct Subclasses

Class Overview

Convenience base class for HTTP client implementations.

Summary

Protected Constructors
AbstractHttpClient ( ClientConnectionManager conman, HttpParams params)
Creates a new HTTP client.
Public Methods
synchronized void addRequestInterceptor ( HttpRequestInterceptor itcp)
synchronized void addRequestInterceptor ( HttpRequestInterceptor itcp, int index)
synchronized void addResponseInterceptor ( HttpResponseInterceptor itcp, int index)
synchronized void addResponseInterceptor ( HttpResponseInterceptor itcp)
synchronized void clearRequestInterceptors ()
synchronized void clearResponseInterceptors ()
final HttpResponse execute ( HttpUriRequest request)
Executes a request using the default context.
<T> T , org.apache.http.protocol.HttpContext)">execute ( HttpUriRequest request, ResponseHandler <? extends T> responseHandler, HttpContext context)
Executes a request using the given context and processes the response using the given response handler.
final HttpResponse execute ( HttpUriRequest request, HttpContext context)
<T> T )">execute ( HttpHost target, HttpRequest request, ResponseHandler <? extends T> responseHandler)
Executes a request to the target using the default context and processes the response using the given response handler.
final HttpResponse execute ( HttpHost target, HttpRequest request)
Executes a request to the target using the default context.
final HttpResponse execute ( HttpHost target, HttpRequest request, HttpContext context)
Executes a request to the target using the given context.
<T> T , org.apache.http.protocol.HttpContext)">execute ( HttpHost target, HttpRequest request, ResponseHandler <? extends T> responseHandler, HttpContext context)
Executes a request to the target using the given context and processes the response using the given response handler.
<T> T )">execute ( HttpUriRequest request, ResponseHandler <? extends T> responseHandler)
Executes a request using the default context and processes the response using the given response handler.
synchronized final AuthSchemeRegistry getAuthSchemes ()
synchronized final ConnectionKeepAliveStrategy getConnectionKeepAliveStrategy ()
synchronized final ClientConnectionManager getConnectionManager ()
Obtains the connection manager used by this client.
synchronized final ConnectionReuseStrategy getConnectionReuseStrategy ()
synchronized final CookieSpecRegistry getCookieSpecs ()
synchronized final CookieStore getCookieStore ()
synchronized final CredentialsProvider getCredentialsProvider ()
synchronized final HttpRequestRetryHandler getHttpRequestRetryHandler ()
synchronized final HttpParams getParams ()
Obtains the parameters for this client.
synchronized final AuthenticationHandler getProxyAuthenticationHandler ()
synchronized final RedirectHandler getRedirectHandler ()
synchronized final HttpRequestExecutor getRequestExecutor ()
synchronized HttpRequestInterceptor getRequestInterceptor (int index)
synchronized int getRequestInterceptorCount ()
synchronized HttpResponseInterceptor getResponseInterceptor (int index)
synchronized int getResponseInterceptorCount ()
synchronized final HttpRoutePlanner getRoutePlanner ()
synchronized final AuthenticationHandler getTargetAuthenticationHandler ()
synchronized final UserTokenHandler getUserTokenHandler ()
void )">removeRequestInterceptorByClass ( Class <? extends  HttpRequestInterceptor > clazz)
void )">removeResponseInterceptorByClass ( Class <? extends  HttpResponseInterceptor > clazz)
synchronized void setAuthSchemes ( AuthSchemeRegistry authSchemeRegistry)
synchronized void setCookieSpecs ( CookieSpecRegistry cookieSpecRegistry)
synchronized void setCookieStore ( CookieStore cookieStore)
synchronized void setCredentialsProvider ( CredentialsProvider credsProvider)
synchronized void setHttpRequestRetryHandler ( HttpRequestRetryHandler retryHandler)
synchronized void setKeepAliveStrategy ( ConnectionKeepAliveStrategy keepAliveStrategy)
synchronized void setParams ( HttpParams params)
Replaces the parameters.
synchronized void setProxyAuthenticationHandler ( AuthenticationHandler proxyAuthHandler)
synchronized void setRedirectHandler ( RedirectHandler redirectHandler)
synchronized void setReuseStrategy ( ConnectionReuseStrategy reuseStrategy)
synchronized void setRoutePlanner ( HttpRoutePlanner routePlanner)
synchronized void setTargetAuthenticationHandler ( AuthenticationHandler targetAuthHandler)
synchronized void setUserTokenHandler ( UserTokenHandler userTokenHandler)
Protected Methods
abstract AuthSchemeRegistry createAuthSchemeRegistry ()
abstract ClientConnectionManager createClientConnectionManager ()
RequestDirector createClientRequestDirector ( HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler stateHandler, HttpParams params)
abstract ConnectionKeepAliveStrategy createConnectionKeepAliveStrategy ()
abstract ConnectionReuseStrategy createConnectionReuseStrategy ()
abstract CookieSpecRegistry createCookieSpecRegistry ()
abstract CookieStore createCookieStore ()
abstract CredentialsProvider createCredentialsProvider ()
abstract HttpContext createHttpContext ()
abstract HttpParams createHttpParams ()
abstract BasicHttpProcessor createHttpProcessor ()
abstract HttpRequestRetryHandler createHttpRequestRetryHandler ()
abstract HttpRoutePlanner createHttpRoutePlanner ()
abstract AuthenticationHandler createProxyAuthenticationHandler ()
abstract RedirectHandler createRedirectHandler ()
abstract HttpRequestExecutor createRequestExecutor ()
abstract AuthenticationHandler createTargetAuthenticationHandler ()
abstract UserTokenHandler createUserTokenHandler ()
HttpParams determineParams ( HttpRequest req)
Obtains parameters for executing a request.
synchronized final BasicHttpProcessor getHttpProcessor ()
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.client.HttpClient

Protected Constructors

protected AbstractHttpClient ( ClientConnectionManager conman, HttpParams params)

Added in API level 1

Creates a new HTTP client.

Parameters
conman the connection manager
params the parameters

Public Methods

public synchronized void addRequestInterceptor ( HttpRequestInterceptor itcp)

Added in API level 1

public synchronized void addRequestInterceptor ( HttpRequestInterceptor itcp, int index)

Added in API level 1

public synchronized void addResponseInterceptor ( HttpResponseInterceptor itcp, int index)

Added in API level 1

public synchronized void addResponseInterceptor ( HttpResponseInterceptor itcp)

Added in API level 1

public synchronized void clearRequestInterceptors ()

Added in API level 1

public synchronized void clearResponseInterceptors ()

Added in API level 1

public final HttpResponse execute ( HttpUriRequest request)

Added in API level 1

Executes a request using the default context.

Parameters
request the request to execute
Returns
  • the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.
, org.apache.http.protocol.HttpContext)">

public T execute ( HttpUriRequest request, ResponseHandler <? extends T> responseHandler, HttpContext context)

Added in API level 1

Executes a request using the given context and processes the response using the given response handler.

Parameters
request the request to execute
responseHandler the response handler
Returns
  • the response object as generated by the response handler.

public final HttpResponse execute ( HttpUriRequest request, HttpContext context)

Added in API level 1

Maps to execute(target, request, context) . The target is determined from the URI of the request.

Parameters
request the request to execute
context the request-specific execution context, or null to use a default context
Returns
  • the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.
)">

public T execute ( HttpHost target, HttpRequest request, ResponseHandler <? extends T> responseHandler)

Added in API level 1

Executes a request to the target using the default context and processes the response using the given response handler.

Parameters
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
responseHandler the response handler
Returns
  • the response object as generated by the response handler.

public final HttpResponse execute ( HttpHost target, HttpRequest request)

Added in API level 1

Executes a request to the target using the default context.

Parameters
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
Returns
  • the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.

public final HttpResponse execute ( HttpHost target, HttpRequest request, HttpContext context)

Added in API level 1

Executes a request to the target using the given context.

Parameters
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
context the context to use for the execution, or null to use the default context
Returns
  • the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.
, org.apache.http.protocol.HttpContext)">

public T execute ( HttpHost target, HttpRequest request, ResponseHandler <? extends T> responseHandler, HttpContext context)

Added in API level 1

Executes a request to the target using the given context and processes the response using the given response handler.

Parameters
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
responseHandler the response handler
context the context to use for the execution, or null to use the default context
Returns
  • the response object as generated by the response handler.
)">

public T execute ( HttpUriRequest request, ResponseHandler <? extends T> responseHandler)

Added in API level 1

Executes a request using the default context and processes the response using the given response handler.

Parameters
request the request to execute
responseHandler the response handler
Returns
  • the response object as generated by the response handler.

public final synchronized AuthSchemeRegistry getAuthSchemes ()

Added in API level 1

public final synchronized ConnectionKeepAliveStrategy getConnectionKeepAliveStrategy ()

Added in API level 1

public final synchronized ClientConnectionManager getConnectionManager ()

Added in API level 1

Obtains the connection manager used by this client.

Returns
  • the connection manager

public final synchronized ConnectionReuseStrategy getConnectionReuseStrategy ()

Added in API level 1

public final synchronized CookieSpecRegistry getCookieSpecs ()

Added in API level 1

public final synchronized CookieStore getCookieStore ()

Added in API level 1

public final synchronized CredentialsProvider getCredentialsProvider ()

Added in API level 1

public final synchronized HttpRequestRetryHandler getHttpRequestRetryHandler ()

Added in API level 1

public final synchronized HttpParams getParams ()

Added in API level 1

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

public final synchronized AuthenticationHandler getProxyAuthenticationHandler ()

Added in API level 1

public final synchronized RedirectHandler getRedirectHandler ()

Added in API level 1

public final synchronized HttpRequestExecutor getRequestExecutor ()

Added in API level 1

public synchronized HttpRequestInterceptor getRequestInterceptor (int index)

Added in API level 1

public synchronized int getRequestInterceptorCount ()

Added in API level 1

public synchronized HttpResponseInterceptor getResponseInterceptor (int index)

Added in API level 1

public synchronized int getResponseInterceptorCount ()

Added in API level 1

public final synchronized HttpRoutePlanner getRoutePlanner ()

Added in API level 1

public final synchronized AuthenticationHandler getTargetAuthenticationHandler ()

Added in API level 1

public final synchronized UserTokenHandler getUserTokenHandler ()

Added in API level 1

)">

public void removeRequestInterceptorByClass ( Class <? extends  HttpRequestInterceptor > clazz)

Added in API level 1

)">

public void removeResponseInterceptorByClass ( Class <? extends  HttpResponseInterceptor > clazz)

Added in API level 1

public synchronized void setAuthSchemes ( AuthSchemeRegistry authSchemeRegistry)

Added in API level 1

public synchronized void setCookieSpecs ( CookieSpecRegistry cookieSpecRegistry)

Added in API level 1

public synchronized void setCookieStore ( CookieStore cookieStore)

Added in API level 1

public synchronized void setCredentialsProvider ( CredentialsProvider credsProvider)

Added in API level 1

public synchronized void setHttpRequestRetryHandler ( HttpRequestRetryHandler retryHandler)

Added in API level 1

public synchronized void setKeepAliveStrategy ( ConnectionKeepAliveStrategy keepAliveStrategy)

Added in API level 1

public synchronized void setParams ( HttpParams params)

Added in API level 1

Replaces the parameters. The implementation here does not update parameters of dependent objects.

Parameters
params the new default parameters

public synchronized void setProxyAuthenticationHandler ( AuthenticationHandler proxyAuthHandler)

Added in API level 1

public synchronized void setRedirectHandler ( RedirectHandler redirectHandler)

Added in API level 1

public synchronized void setReuseStrategy ( ConnectionReuseStrategy reuseStrategy)

Added in API level 1

public synchronized void setRoutePlanner ( HttpRoutePlanner routePlanner)

Added in API level 1

public synchronized void setTargetAuthenticationHandler ( AuthenticationHandler targetAuthHandler)

Added in API level 1

public synchronized void setUserTokenHandler ( UserTokenHandler userTokenHandler)

Added in API level 1

Protected Methods

protected abstract AuthSchemeRegistry createAuthSchemeRegistry ()

Added in API level 1

protected abstract ClientConnectionManager createClientConnectionManager ()

Added in API level 1

protected RequestDirector createClientRequestDirector ( HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler stateHandler, HttpParams params)

Added in API level 1

protected abstract ConnectionKeepAliveStrategy createConnectionKeepAliveStrategy ()

Added in API level 1

protected abstract ConnectionReuseStrategy createConnectionReuseStrategy ()

Added in API level 1

protected abstract CookieSpecRegistry createCookieSpecRegistry ()

Added in API level 1

protected abstract CookieStore createCookieStore ()

Added in API level 1

protected abstract CredentialsProvider createCredentialsProvider ()

Added in API level 1

protected abstract HttpContext createHttpContext ()

Added in API level 1

protected abstract HttpParams createHttpParams ()

Added in API level 1

protected abstract BasicHttpProcessor createHttpProcessor ()

Added in API level 1

protected abstract HttpRequestRetryHandler createHttpRequestRetryHandler ()

Added in API level 1

protected abstract HttpRoutePlanner createHttpRoutePlanner ()

Added in API level 1

protected abstract AuthenticationHandler createProxyAuthenticationHandler ()

Added in API level 1

protected abstract RedirectHandler createRedirectHandler ()

Added in API level 1

protected abstract HttpRequestExecutor createRequestExecutor ()

Added in API level 1

protected abstract AuthenticationHandler createTargetAuthenticationHandler ()

Added in API level 1

protected abstract UserTokenHandler createUserTokenHandler ()

Added in API level 1

protected HttpParams determineParams ( HttpRequest req)

Added in API level 1

Obtains parameters for executing a request. The default implementation in this class creates a new ClientParamsStack from the request parameters and the client parameters.
This method is called by the default implementation of execute(HttpHost, HttpRequest, HttpContext) to obtain the parameters for the DefaultRequestDirector .

Parameters
req the request that will be executed
Returns
  • the parameters to use

protected final synchronized BasicHttpProcessor getHttpProcessor ()

Added in API level 1