org.springframework.http.client

## Class CommonsClientHttpRequestFactory

- java.lang.Object
- - org.springframework.http.client.CommonsClientHttpRequestFactory

All Implemented Interfaces:
  DisposableBean, ClientHttpRequestFactory

Deprecated.
In favor of `HttpComponentsClientHttpRequestFactory`

    @Deprecated
    public class CommonsClientHttpRequestFactory
    extends Object
    implements ClientHttpRequestFactory, DisposableBean

`ClientHttpRequestFactory` implementation that uses Jakarta Commons HttpClient to create requests.

Allows to use a pre-configured `HttpClient` instance - potentially with authentication, HTTP connection pooling, etc.

Since:
  3.0
Author:
  Arjen Poutsma
See Also:
  `SimpleClientHttpRequestFactory`

### Constructor Summary

Constructors
Constructor and Description
`CommonsClientHttpRequestFactory()` Deprecated. Create a new instance of the `CommonsHttpRequestFactory` with a default `HttpClient` that uses a default `MultiThreadedHttpConnectionManager`.
`CommonsClientHttpRequestFactory(HttpClient httpClient)` Deprecated. Create a new instance of the `CommonsHttpRequestFactory` with the given `HttpClient` instance.

### Method Summary

Methods
`protected HttpMethodBase` `createCommonsHttpMethod(HttpMethod httpMethod, String uri)` Deprecated. Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
`ClientHttpRequest` `createRequest(URI uri, HttpMethod httpMethod)` Deprecated. Create a new `ClientHttpRequest` for the specified URI and HTTP method.
`void` `destroy()` Deprecated. Shutdown hook that closes the underlying `HttpConnectionManager`'s connection pool, if any.
`HttpClient` `getHttpClient()` Deprecated. Return the `HttpClient` used by this factory.
`protected void` `postProcessCommonsHttpMethod(HttpMethodBase httpMethod)` Deprecated. Template method that allows for manipulating the `HttpMethodBase` before it is returned as part of a `CommonsClientHttpRequest`.
`void` `setConnectTimeout(int timeout)` Deprecated. Set the connection timeout for the underlying HttpClient.
`void` `setHttpClient(HttpClient httpClient)` Deprecated. Set the `HttpClient` used by this factory.
`void` `setReadTimeout(int timeout)` Deprecated. Set the socket read timeout for the underlying HttpClient.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CommonsClientHttpRequestFactory

    public CommonsClientHttpRequestFactory()

Deprecated.
Create a new instance of the `CommonsHttpRequestFactory` with a default `HttpClient` that uses a default `MultiThreadedHttpConnectionManager`.

#### CommonsClientHttpRequestFactory

    public CommonsClientHttpRequestFactory(HttpClient httpClient)

Deprecated.
Create a new instance of the `CommonsHttpRequestFactory` with the given `HttpClient` instance.

Parameters:
  `httpClient` - the HttpClient instance to use for this factory

### Method Detail

#### setHttpClient

    public void setHttpClient(HttpClient httpClient)

Deprecated.
Set the `HttpClient` used by this factory.

#### getHttpClient

    public HttpClient getHttpClient()

Deprecated.
Return the `HttpClient` used by this factory.

#### setConnectTimeout

    public void setConnectTimeout(int timeout)

Deprecated.
Set the connection timeout for the underlying HttpClient. A timeout value of 0 specifies an infinite timeout.

Parameters:
  `timeout` - the timeout value in milliseconds
See Also:
  `HttpConnectionParams.setConnectionTimeout(int)`

#### setReadTimeout

    public void setReadTimeout(int timeout)

Deprecated.
Set the socket read timeout for the underlying HttpClient. A timeout value of 0 specifies an infinite timeout.

Parameters:
  `timeout` - the timeout value in milliseconds
See Also:
  `HttpConnectionParams.setSoTimeout(int)`

#### createRequest

    public ClientHttpRequest createRequest(URI uri,
                                  HttpMethod httpMethod)
                                    throws IOException

Deprecated.
Description copied from interface: `ClientHttpRequestFactory`
Create a new `ClientHttpRequest` for the specified URI and HTTP method.

The returned request can be written to, and then executed by calling `ClientHttpRequest.execute()`.

Specified by:
  `createRequest` in interface `ClientHttpRequestFactory`
Parameters:
  `uri` - the URI to create a request for
  `httpMethod` - the HTTP method to execute
Returns:
  the created request
Throws:
  `IOException` - in case of I/O errors

#### createCommonsHttpMethod

    protected HttpMethodBase createCommonsHttpMethod(HttpMethod httpMethod,
                                         String uri)

Deprecated.
Create a Commons HttpMethodBase object for the given HTTP method and URI specification.

Parameters:
  `httpMethod` - the HTTP method
  `uri` - the URI
Returns:
  the Commons HttpMethodBase object

#### postProcessCommonsHttpMethod

    protected void postProcessCommonsHttpMethod(HttpMethodBase httpMethod)

Deprecated.
Template method that allows for manipulating the `HttpMethodBase` before it is returned as part of a `CommonsClientHttpRequest`.

The default implementation is empty.

Parameters:
  `httpMethod` - the Commons HTTP method object to process

#### destroy

    public void destroy()

Deprecated.
Shutdown hook that closes the underlying `HttpConnectionManager`'s connection pool, if any.

Specified by:
  `destroy` in interface `DisposableBean`