English | Site Directory

Android - An Open Handset Alliance Project

org.apache.http.impl.client
public abstract class

org.apache.http.impl.client.AbstractHttpClient

java.lang.Object
org.apache.http.impl.client.AbstractHttpClient HttpClient HttpRequestInterceptorList HttpResponseInterceptorList

Convenience base class for HTTP client implementations.

Known Direct Subclasses

Summary

Protected Constructors

          AbstractHttpClient(ClientConnectionManager conman, HttpParams params)
Creates a new HTTP client.

Public Methods

  synchronized      void  addRequestInterceptor(HttpRequestInterceptor itcp)
Appends a request interceptor to this list.
  synchronized      void  addRequestInterceptor(HttpRequestInterceptor itcp, int index)
Inserts a request interceptor at the specified index.
  synchronized      void  addResponseInterceptor(HttpResponseInterceptor itcp, int index)
Inserts a response interceptor at the specified index.
  synchronized      void  addResponseInterceptor(HttpResponseInterceptor itcp)
Appends a response interceptor to this list.
  synchronized      void  clearRequestInterceptors()
Removes all request interceptors from this list.
  synchronized      void  clearResponseInterceptors()
Removes all response interceptors from this list.
    final    HttpResponse  execute(HttpUriRequest request, HttpContext context)
Maps to execute(roureq, context).
    final    HttpResponse  execute(RoutedRequest roureq, HttpContext context)
Executes a request along the given route.
    final    HttpResponse  execute(HttpUriRequest request)
Executes a request using the default context.
        HttpResponse  execute(RoutedRequest roureq)
Executes a request along the given route using the default context.
  synchronized  final    AuthSchemeRegistry  getAuthSchemes()
  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    HttpContext  getDefaultContext()
Obtains the default context used by this client populated with default attributes.
  synchronized  final    HttpRequestRetryHandler  getHttpRequestRetryHandler()
  synchronized  final    HttpParams  getParams()
Obtains the parameters for this client.
  synchronized  final    AuthenticationHandler  getProxyAuthenticationHandler()
  synchronized  final    RedirectHandler  getRedirectHandler()
  synchronized      HttpRequestInterceptor  getRequestInterceptor(int index)
Obtains a request interceptor from this list.
  synchronized      int  getRequestInterceptorCount()
Obtains the current size of this list.
  synchronized      HttpResponseInterceptor  getResponseInterceptor(int index)
Obtains a response interceptor from this list.
  synchronized      int  getResponseInterceptorCount()
Obtains the current size of this list.
  synchronized  final    HttpRoutePlanner  getRoutePlanner()
  synchronized  final    AuthenticationHandler  getTargetAuthenticationHandler()
        void  removeRequestInterceptorByClass(Class clazz)
Removes all request interceptor of the specified class
        void  removeResponseInterceptorByClass(Class clazz)
Removes all response interceptor of the specified class
  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  setInterceptors(List itcps)
Sets the request interceptors in this list.
  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)

Protected Methods

abstract        AuthSchemeRegistry  createAuthSchemeRegistry()
abstract        ClientConnectionManager  createClientConnectionManager()
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        AuthenticationHandler  createTargetAuthenticationHandler()
        HttpParams  determineParams(HttpRequest req)
Obtains parameters for executing a request.
abstract        RoutedRequest  determineRoute(HttpHost target, HttpRequest request, HttpContext context)
Determines the route for a request.
  synchronized  final    BasicHttpProcessor  getHttpProcessor()
abstract        void  populateContext(HttpContext context)
Methods inherited from class java.lang.Object
Methods inherited from interface org.apache.http.protocol.HttpResponseInterceptorList
Methods inherited from interface org.apache.http.client.HttpClient
Methods inherited from interface org.apache.http.protocol.HttpRequestInterceptorList

Details

Protected Constructors

protected AbstractHttpClient(ClientConnectionManager conman, HttpParams params)

Creates a new HTTP client.

Parameters

conman the connection manager
params the parameters

Public Methods

public synchronized void addRequestInterceptor(HttpRequestInterceptor itcp)

Appends a request interceptor to this list.

public synchronized void addRequestInterceptor(HttpRequestInterceptor itcp, int index)

Inserts a request interceptor at the specified index.

public synchronized void addResponseInterceptor(HttpResponseInterceptor itcp, int index)

Inserts a response interceptor at the specified index.

public synchronized void addResponseInterceptor(HttpResponseInterceptor itcp)

Appends a response interceptor to this list.

public synchronized void clearRequestInterceptors()

Removes all request interceptors from this list.

public synchronized void clearResponseInterceptors()

Removes all response interceptors from this list.

public final HttpResponse execute(HttpUriRequest request, HttpContext context)

Maps to execute(roureq, context). The route is computed by determineRoute.

Parameters

request the request to execute
context the request-specific execution context, or null to use a default context

public final HttpResponse execute(RoutedRequest roureq, HttpContext context)

Executes a request along the given route.

public final HttpResponse execute(HttpUriRequest request)

Executes a request using the default context. See there for details.

public HttpResponse execute(RoutedRequest roureq)

Executes a request along the given route using the default context.

public final synchronized AuthSchemeRegistry getAuthSchemes()

public final synchronized ClientConnectionManager getConnectionManager()

Obtains the connection manager used by this client.

public final synchronized ConnectionReuseStrategy getConnectionReuseStrategy()

public final synchronized CookieSpecRegistry getCookieSpecs()

public final synchronized CookieStore getCookieStore()

public final synchronized CredentialsProvider getCredentialsProvider()

public final synchronized HttpContext getDefaultContext()

Obtains the default context used by this client populated with default attributes. This context will be used by default when executing requests with this client.

public final synchronized HttpRequestRetryHandler getHttpRequestRetryHandler()

public final synchronized HttpParams getParams()

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.

public final synchronized AuthenticationHandler getProxyAuthenticationHandler()

public final synchronized RedirectHandler getRedirectHandler()

public synchronized HttpRequestInterceptor getRequestInterceptor(int index)

Obtains a request interceptor from this list.

public synchronized int getRequestInterceptorCount()

Obtains the current size of this list.

public synchronized HttpResponseInterceptor getResponseInterceptor(int index)

Obtains a response interceptor from this list.

public synchronized int getResponseInterceptorCount()

Obtains the current size of this list.

public final synchronized HttpRoutePlanner getRoutePlanner()

public final synchronized AuthenticationHandler getTargetAuthenticationHandler()

public void removeRequestInterceptorByClass(Class clazz)

Removes all request interceptor of the specified class

public void removeResponseInterceptorByClass(Class clazz)

Removes all response interceptor of the specified class

public synchronized void setAuthSchemes(AuthSchemeRegistry authSchemeRegistry)

public synchronized void setCookieSpecs(CookieSpecRegistry cookieSpecRegistry)

public synchronized void setCookieStore(CookieStore cookieStore)

public synchronized void setCredentialsProvider(CredentialsProvider credsProvider)

public synchronized void setHttpRequestRetryHandler(HttpRequestRetryHandler retryHandler)

public synchronized void setInterceptors(List itcps)

Sets the request interceptors in this list. This list will be cleared and re-initialized to contain all request interceptors from the argument list. If the argument list includes elements that are not request interceptors, the behavior is implementation dependent.

public synchronized void setParams(HttpParams params)

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)

public synchronized void setRedirectHandler(RedirectHandler redirectHandler)

public synchronized void setReuseStrategy(ConnectionReuseStrategy reuseStrategy)

public synchronized void setRoutePlanner(HttpRoutePlanner routePlanner)

public synchronized void setTargetAuthenticationHandler(AuthenticationHandler targetAuthHandler)

Protected Methods

protected abstract AuthSchemeRegistry createAuthSchemeRegistry()

protected abstract ClientConnectionManager createClientConnectionManager()

protected abstract ConnectionReuseStrategy createConnectionReuseStrategy()

protected abstract CookieSpecRegistry createCookieSpecRegistry()

protected abstract CookieStore createCookieStore()

protected abstract CredentialsProvider createCredentialsProvider()

protected abstract HttpContext createHttpContext()

protected abstract HttpParams createHttpParams()

protected abstract BasicHttpProcessor createHttpProcessor()

protected abstract HttpRequestRetryHandler createHttpRequestRetryHandler()

protected abstract HttpRoutePlanner createHttpRoutePlanner()

protected abstract AuthenticationHandler createProxyAuthenticationHandler()

protected abstract RedirectHandler createRedirectHandler()

protected abstract AuthenticationHandler createTargetAuthenticationHandler()

protected HttpParams determineParams(HttpRequest req)

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(RoutedRequest, HttpContext) to obtain the parameters for the DefaultClientRequestDirector.

Parameters

req the request that will be executed

Returns

  • the parameters to use

protected abstract RoutedRequest determineRoute(HttpHost target, HttpRequest request, HttpContext context)

Determines the route for a request. Called by execute(urirequest, context) to map to execute(roureq, 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, never null

Returns

  • the request along with the route it should take

Throws

HttpException in case of a problem

protected final synchronized BasicHttpProcessor getHttpProcessor()

protected abstract void populateContext(HttpContext context)

Build m5-rc15i - 10 Jun 2008 13:54