## org.apache.http.impl.client
Class DefaultHttpClient

    java.lang.Object
      org.apache.http.impl.client.AbstractHttpClient
          org.apache.http.impl.client.DefaultHttpClient

All Implemented Interfaces:
  HttpClient

Direct Known Subclasses:
  ContentEncodingHttpClient

    @ThreadSafe
    public class DefaultHttpClient

extends AbstractHttpClient

Default implementation of `HttpClient` pre-configured for most common use scenarios.

This class creates the following chain of protocol interceptors per default:

- `RequestDefaultHeaders`
- `RequestContent`
- `RequestTargetHost`
- `RequestClientConnControl`
- `RequestUserAgent`
- `RequestExpectContinue`
- `RequestAddCookies`
- `ResponseProcessCookies`
- `RequestTargetAuthentication`
- `RequestProxyAuthentication`

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_VERSION`
- `CoreProtocolPNames.STRICT_TRANSFER_ENCODING`
- `CoreProtocolPNames.HTTP_ELEMENT_CHARSET`
- `CoreProtocolPNames.USE_EXPECT_CONTINUE`
- `CoreProtocolPNames.WAIT_FOR_CONTINUE`
- `CoreProtocolPNames.USER_AGENT`
- `CoreConnectionPNames.TCP_NODELAY`
- `CoreConnectionPNames.SO_TIMEOUT`
- `CoreConnectionPNames.SO_LINGER`
- `CoreConnectionPNames.SO_REUSEADDR`
- `CoreConnectionPNames.SOCKET_BUFFER_SIZE`
- `CoreConnectionPNames.CONNECTION_TIMEOUT`
- `CoreConnectionPNames.MAX_LINE_LENGTH`
- `CoreConnectionPNames.MAX_HEADER_COUNT`
- `CoreConnectionPNames.STALE_CONNECTION_CHECK`
- `ConnRoutePNames.FORCED_ROUTE`
- `ConnRoutePNames.LOCAL_ADDRESS`
- `ConnRoutePNames.DEFAULT_PROXY`
- `CookieSpecPNames.DATE_PATTERNS`
- `CookieSpecPNames.SINGLE_COOKIE_HEADER`
- `AuthPNames.CREDENTIAL_CHARSET`
- `ClientPNames.COOKIE_POLICY`
- `ClientPNames.HANDLE_AUTHENTICATION`
- `ClientPNames.HANDLE_REDIRECTS`
- `ClientPNames.MAX_REDIRECTS`
- `ClientPNames.ALLOW_CIRCULAR_REDIRECTS`
- `ClientPNames.VIRTUAL_HOST`
- `ClientPNames.DEFAULT_HOST`
- `ClientPNames.DEFAULT_HEADERS`
- `ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME`

Since:
  4.0

Constructor Summary
`DefaultHttpClient()`
`DefaultHttpClient(ClientConnectionManager conman)`
`DefaultHttpClient(ClientConnectionManager conman, HttpParams params)` Creates a new HTTP client from parameters and a connection manager.
`DefaultHttpClient(HttpParams params)`

Method Summary
`protected HttpParams` `createHttpParams()` Creates the default set of HttpParams by invoking `setDefaultHttpParams(HttpParams)`
`protected BasicHttpProcessor` `createHttpProcessor()`
`static void` `setDefaultHttpParams(HttpParams params)` 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, createAuthSchemeRegistry, createClientConnectionManager, createClientRequestDirector, createClientRequestDirector, createConnectionKeepAliveStrategy, createConnectionReuseStrategy, createCookieSpecRegistry, createCookieStore, createCredentialsProvider, createHttpContext, createHttpRequestRetryHandler, createHttpRoutePlanner, createProxyAuthenticationHandler, createRedirectHandler, createRequestExecutor, createTargetAuthenticationHandler, createUserTokenHandler, determineParams, execute, execute, execute, execute, execute, execute, execute, execute, getAuthSchemes, getConnectionKeepAliveStrategy, getConnectionManager, getConnectionReuseStrategy, getCookieSpecs, getCookieStore, getCredentialsProvider, getHttpProcessor, getHttpRequestRetryHandler, getParams, getProxyAuthenticationHandler, getRedirectHandler, getRedirectStrategy, getRequestExecutor, getRequestInterceptor, getRequestInterceptorCount, getResponseInterceptor, getResponseInterceptorCount, getRoutePlanner, getTargetAuthenticationHandler, getUserTokenHandler, removeRequestInterceptorByClass, removeResponseInterceptorByClass, setAuthSchemes, setCookieSpecs, setCookieStore, setCredentialsProvider, setHttpRequestRetryHandler, setKeepAliveStrategy, setParams, setProxyAuthenticationHandler, setRedirectHandler, setRedirectStrategy, setReuseStrategy, setRoutePlanner, setTargetAuthenticationHandler, setUserTokenHandler`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultHttpClient

    public DefaultHttpClient(ClientConnectionManager conman,
                             HttpParams params)

  Creates a new HTTP client from parameters and a connection manager.

  Parameters:
    `params` - the parameters
    `conman` - the connection manager

### DefaultHttpClient

    public DefaultHttpClient(ClientConnectionManager conman)

Since:
  4.1

### DefaultHttpClient

    public DefaultHttpClient(HttpParams params)

### DefaultHttpClient

    public DefaultHttpClient()

Method Detail

### createHttpParams

    protected HttpParams createHttpParams()

  Creates the default set of HttpParams by invoking `setDefaultHttpParams(HttpParams)`

  Specified by:
    `createHttpParams` in class `AbstractHttpClient`
  Returns:
    a new instance of `SyncBasicHttpParams` with the defaults applied to it.

### setDefaultHttpParams

    public static void setDefaultHttpParams(HttpParams params)

  Saves the default set of HttpParams in the provided parameter. These are:
  - `CoreProtocolPNames.PROTOCOL_VERSION`: 1.1
  - `CoreProtocolPNames.HTTP_CONTENT_CHARSET`: ISO-8859-1
  - `CoreConnectionPNames.TCP_NODELAY`: true
  - `CoreConnectionPNames.SOCKET_BUFFER_SIZE`: 8192
  - `CoreProtocolPNames.USER_AGENT`: Apache-HttpClient/<release> (java 1.5)

### createHttpProcessor

    protected BasicHttpProcessor createHttpProcessor()

  Specified by:
    `createHttpProcessor` in class `AbstractHttpClient`

Copyright © 1999-2011 The Apache Software Foundation. All Rights Reserved.