Package org.apache.http.impl.client
Class AbstractHttpClient
java.lang.Object
org.apache.http.impl.client.AbstractHttpClient
- All Implemented Interfaces:
HttpClient
- Direct Known Subclasses:
DefaultHttpClient
public abstract class AbstractHttpClient extends Object implements HttpClient
Convenience base class for HTTP client implementations.
- Since:
- 4.0
- Version:
- $Revision: 677250 $
- Author:
- Roland Weber, Oleg Kalnichevski
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHttpClient(ClientConnectionManager conman, HttpParams params)Creates a new HTTP client. -
Method Summary
-
Constructor Details
-
AbstractHttpClient
Creates a new HTTP client.- Parameters:
conman- the connection managerparams- the parameters
-
-
Method Details
-
createHttpParams
-
createHttpContext
-
createRequestExecutor
-
createClientConnectionManager
-
createAuthSchemeRegistry
-
createCookieSpecRegistry
-
createConnectionReuseStrategy
-
createConnectionKeepAliveStrategy
-
createHttpProcessor
-
createHttpRequestRetryHandler
-
createRedirectHandler
-
createTargetAuthenticationHandler
-
createProxyAuthenticationHandler
-
createCookieStore
-
createCredentialsProvider
-
createHttpRoutePlanner
-
createUserTokenHandler
-
getParams
Description copied from interface:HttpClientObtains 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.- Specified by:
getParamsin interfaceHttpClient- Returns:
- the default parameters
-
setParams
Replaces the parameters. The implementation here does not update parameters of dependent objects.- Parameters:
params- the new default parameters
-
getConnectionManager
Description copied from interface:HttpClientObtains the connection manager used by this client.- Specified by:
getConnectionManagerin interfaceHttpClient- Returns:
- the connection manager
-
getRequestExecutor
-
getAuthSchemes
-
setAuthSchemes
-
getCookieSpecs
-
setCookieSpecs
-
getConnectionReuseStrategy
-
setReuseStrategy
-
getConnectionKeepAliveStrategy
-
setKeepAliveStrategy
-
getHttpRequestRetryHandler
-
setHttpRequestRetryHandler
-
getRedirectHandler
-
setRedirectHandler
-
getTargetAuthenticationHandler
-
setTargetAuthenticationHandler
-
getProxyAuthenticationHandler
-
setProxyAuthenticationHandler
-
getCookieStore
-
setCookieStore
-
getCredentialsProvider
-
setCredentialsProvider
-
getRoutePlanner
-
setRoutePlanner
-
getUserTokenHandler
-
setUserTokenHandler
-
getHttpProcessor
-
addResponseInterceptor
-
addResponseInterceptor
-
getResponseInterceptor
-
getResponseInterceptorCount
public int getResponseInterceptorCount() -
clearResponseInterceptors
public void clearResponseInterceptors() -
removeResponseInterceptorByClass
-
addRequestInterceptor
-
addRequestInterceptor
-
getRequestInterceptor
-
getRequestInterceptorCount
public int getRequestInterceptorCount() -
clearRequestInterceptors
public void clearRequestInterceptors() -
removeRequestInterceptorByClass
-
execute
public final HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolExceptionDescription copied from interface:HttpClientExecutes a request using the default context.- Specified by:
executein interfaceHttpClient- 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.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-
execute
public final HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolExceptionMaps toexecute(target, request, context). The target is determined from the URI of the request.- Specified by:
executein interfaceHttpClient- Parameters:
request- the request to executecontext- the request-specific execution context, ornullto 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.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-
execute
public final HttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolExceptionDescription copied from interface:HttpClientExecutes a request to the target using the default context.- Specified by:
executein interfaceHttpClient- Parameters:
target- the target host for the request. Implementations may acceptnullif 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.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-
execute
public final HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolExceptionDescription copied from interface:HttpClientExecutes a request to the target using the given context.- Specified by:
executein interfaceHttpClient- Parameters:
target- the target host for the request. Implementations may acceptnullif 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, ornullto 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.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-
createClientRequestDirector
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) -
determineParams
Obtains parameters for executing a request. The default implementation in this class creates a newClientParamsStackfrom the request parameters and the client parameters.
This method is called by the default implementation ofexecute(HttpHost,HttpRequest,HttpContext)to obtain the parameters for theDefaultRequestDirector.- Parameters:
req- the request that will be executed- Returns:
- the parameters to use
-
execute
public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolExceptionDescription copied from interface:HttpClientExecutes a request using the default context and processes the response using the given response handler.- Specified by:
executein interfaceHttpClient- Parameters:
request- the request to executeresponseHandler- the response handler- Returns:
- the response object as generated by the response handler.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-
execute
public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException, ClientProtocolExceptionDescription copied from interface:HttpClientExecutes a request using the given context and processes the response using the given response handler.- Specified by:
executein interfaceHttpClient- Parameters:
request- the request to executeresponseHandler- the response handler- Returns:
- the response object as generated by the response handler.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-
execute
public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolExceptionDescription copied from interface:HttpClientExecutes a request to the target using the default context and processes the response using the given response handler.- Specified by:
executein interfaceHttpClient- Parameters:
target- the target host for the request. Implementations may acceptnullif 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- Returns:
- the response object as generated by the response handler.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-
execute
public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException, ClientProtocolExceptionDescription copied from interface:HttpClientExecutes a request to the target using the given context and processes the response using the given response handler.- Specified by:
executein interfaceHttpClient- Parameters:
target- the target host for the request. Implementations may acceptnullif 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, ornullto use the default context- Returns:
- the response object as generated by the response handler.
- Throws:
IOException- in case of a problem or the connection was abortedClientProtocolException- in case of an http protocol error
-