Package org.apache.http.impl.client
Class DefaultHttpClient
java.lang.Object
org.apache.http.impl.client.CloseableHttpClient
org.apache.http.impl.client.AbstractHttpClient
org.apache.http.impl.client.DefaultHttpClient
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpClient
- Direct Known Subclasses:
ContentEncodingHttpClient,SystemDefaultHttpClient
@Contract(threading=SAFE_CONDITIONAL)
@Deprecated
public class DefaultHttpClient
extends AbstractHttpClient
Deprecated.
Default implementation of
HttpClient pre-configured
for most common use scenarios.
Please see the Javadoc for createHttpProcessor() for the details of the interceptors
that are set up by default.
Additional interceptors can be added as follows, but take care not to add the same interceptor more than once.
DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.addRequestInterceptor(new RequestAcceptEncoding()); httpclient.addResponseInterceptor(new ResponseContentEncoding());
This class sets up the following parameters if not explicitly set:
- Version: HttpVersion.HTTP_1_1
- ContentCharset: HTTP.DEFAULT_CONTENT_CHARSET
- NoTcpDelay: true
- SocketBufferSize: 8192
- UserAgent: Apache-HttpClient/release (java 1.5)
The following parameters can be used to customize the behavior of this class:
CoreProtocolPNames.PROTOCOL_VERSIONCoreProtocolPNames.STRICT_TRANSFER_ENCODINGCoreProtocolPNames.HTTP_ELEMENT_CHARSETCoreProtocolPNames.USE_EXPECT_CONTINUECoreProtocolPNames.WAIT_FOR_CONTINUECoreProtocolPNames.USER_AGENTCoreConnectionPNames.TCP_NODELAYCoreConnectionPNames.SO_TIMEOUTCoreConnectionPNames.SO_LINGERCoreConnectionPNames.SO_REUSEADDRCoreConnectionPNames.SOCKET_BUFFER_SIZECoreConnectionPNames.CONNECTION_TIMEOUTCoreConnectionPNames.MAX_LINE_LENGTHCoreConnectionPNames.MAX_HEADER_COUNTCoreConnectionPNames.STALE_CONNECTION_CHECKConnRoutePNames.FORCED_ROUTEConnRoutePNames.LOCAL_ADDRESSConnRoutePNames.DEFAULT_PROXYCookieSpecPNames.DATE_PATTERNSCookieSpecPNames.SINGLE_COOKIE_HEADERAuthPNames.CREDENTIAL_CHARSETClientPNames.COOKIE_POLICYClientPNames.HANDLE_AUTHENTICATIONClientPNames.HANDLE_REDIRECTSClientPNames.MAX_REDIRECTSClientPNames.ALLOW_CIRCULAR_REDIRECTSClientPNames.VIRTUAL_HOSTClientPNames.DEFAULT_HOSTClientPNames.DEFAULT_HEADERSClientPNames.CONN_MANAGER_TIMEOUT
- Since:
- 4.0
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Deprecated.DefaultHttpClient(ClientConnectionManager conman, org.apache.http.params.HttpParams params) Deprecated.Creates a new HTTP client from parameters and a connection manager.DefaultHttpClient(org.apache.http.params.HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.params.HttpParamsDeprecated.Creates the default set of HttpParams by invokingsetDefaultHttpParams(HttpParams)protected org.apache.http.protocol.BasicHttpProcessorDeprecated.Create the processor with the following interceptors:RequestDefaultHeadersRequestContentRequestTargetHostRequestClientConnControlRequestUserAgentRequestExpectContinueRequestAddCookiesResponseProcessCookiesRequestAuthCacheRequestTargetAuthenticationRequestProxyAuthenticationstatic voidsetDefaultHttpParams(org.apache.http.params.HttpParams params) Deprecated.Saves the default set of HttpParams in the provided parameter.Methods inherited from class org.apache.http.impl.client.AbstractHttpClient
addRequestInterceptor, addRequestInterceptor, addResponseInterceptor, addResponseInterceptor, clearRequestInterceptors, clearResponseInterceptors, close, createAuthSchemeRegistry, createClientConnectionManager, createClientRequestDirector, createClientRequestDirector, createClientRequestDirector, createConnectionKeepAliveStrategy, createConnectionReuseStrategy, createCookieSpecRegistry, createCookieStore, createCredentialsProvider, createHttpContext, createHttpRequestRetryHandler, createHttpRoutePlanner, createProxyAuthenticationHandler, createProxyAuthenticationStrategy, createRedirectHandler, createRequestExecutor, createTargetAuthenticationHandler, createTargetAuthenticationStrategy, createUserTokenHandler, determineParams, doExecute, getAuthSchemes, getBackoffManager, getConnectionBackoffStrategy, getConnectionKeepAliveStrategy, getConnectionManager, getConnectionReuseStrategy, getCookieSpecs, getCookieStore, getCredentialsProvider, getHttpProcessor, getHttpRequestRetryHandler, getParams, getProxyAuthenticationHandler, getProxyAuthenticationStrategy, getRedirectHandler, getRedirectStrategy, getRequestExecutor, getRequestInterceptor, getRequestInterceptorCount, getResponseInterceptor, getResponseInterceptorCount, getRoutePlanner, getTargetAuthenticationHandler, getTargetAuthenticationStrategy, getUserTokenHandler, removeRequestInterceptorByClass, removeResponseInterceptorByClass, setAuthSchemes, setBackoffManager, setConnectionBackoffStrategy, setCookieSpecs, setCookieStore, setCredentialsProvider, setHttpRequestRetryHandler, setKeepAliveStrategy, setParams, setProxyAuthenticationHandler, setProxyAuthenticationStrategy, setRedirectHandler, setRedirectStrategy, setReuseStrategy, setRoutePlanner, setTargetAuthenticationHandler, setTargetAuthenticationStrategy, setUserTokenHandler
-
Constructor Details
-
DefaultHttpClient
Deprecated.Creates a new HTTP client from parameters and a connection manager.- Parameters:
params- the parametersconman- the connection manager
-
DefaultHttpClient
Deprecated.- Since:
- 4.1
-
DefaultHttpClient
public DefaultHttpClient(org.apache.http.params.HttpParams params) Deprecated. -
DefaultHttpClient
public DefaultHttpClient()Deprecated.
-
-
Method Details
-
createHttpParams
protected org.apache.http.params.HttpParams createHttpParams()Deprecated.Creates the default set of HttpParams by invokingsetDefaultHttpParams(HttpParams)- Specified by:
createHttpParamsin classAbstractHttpClient- Returns:
- a new instance of
SyncBasicHttpParamswith the defaults applied to it.
-
setDefaultHttpParams
public static void setDefaultHttpParams(org.apache.http.params.HttpParams params) Deprecated.Saves the default set of HttpParams in the provided parameter. These are:CoreProtocolPNames.PROTOCOL_VERSION: 1.1CoreProtocolPNames.HTTP_CONTENT_CHARSET: ISO-8859-1CoreConnectionPNames.TCP_NODELAY: trueCoreConnectionPNames.SOCKET_BUFFER_SIZE: 8192CoreProtocolPNames.USER_AGENT: Apache-HttpClient (Java 1.5)
-
createHttpProcessor
protected org.apache.http.protocol.BasicHttpProcessor createHttpProcessor()Deprecated.Create the processor with the following interceptors:RequestDefaultHeadersRequestContentRequestTargetHostRequestClientConnControlRequestUserAgentRequestExpectContinueRequestAddCookiesResponseProcessCookiesRequestAuthCacheRequestTargetAuthenticationRequestProxyAuthentication
- Specified by:
createHttpProcessorin classAbstractHttpClient- Returns:
- the processor with the added interceptors.
-
HttpClientBuildersee alsoCloseableHttpClient.