Package org.springframework.http.client

# Class JettyClientHttpRequestFactory

java.lang.Object
org.springframework.http.client.JettyClientHttpRequestFactory

All Implemented Interfaces:
  `org.springframework.beans.factory.DisposableBean`, `org.springframework.beans.factory.InitializingBean`, `ClientHttpRequestFactory`

public class JettyClientHttpRequestFactory extends Object implements ClientHttpRequestFactory, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
`ClientHttpRequestFactory` implementation based on Jetty's `HttpClient`.

Since:
  6.1
Author:
  Arjen Poutsma
See Also:
  - Jetty HttpClient

## Constructor Summary

Constructors
Constructor
Description
`JettyClientHttpRequestFactory()`
Default constructor that creates a new instance of `HttpClient`.
`JettyClientHttpRequestFactory(org.eclipse.jetty.client.HttpClient httpClient)`
Constructor that takes a customized `HttpClient` instance.

## Method Summary

Modifier and Type
Method
Description
`void`
`afterPropertiesSet()`
`ClientHttpRequest`
`createRequest(URI uri, HttpMethod httpMethod)`
Create a new `ClientHttpRequest` for the specified URI and HTTP method.
`void`
`destroy()`
`void`
`setConnectTimeout(int connectTimeout)`
Set the underlying connect timeout in milliseconds.
`void`
`setConnectTimeout(Duration connectTimeout)`
Set the underlying connect timeout in milliseconds.
`void`
`setReadTimeout(long readTimeout)`
Set the underlying read timeout in milliseconds.
`void`
`setReadTimeout(Duration readTimeout)`
Set the underlying read timeout as `Duration`.

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

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

## Constructor Details

### JettyClientHttpRequestFactory

public JettyClientHttpRequestFactory()
Default constructor that creates a new instance of `HttpClient`.

### JettyClientHttpRequestFactory

public JettyClientHttpRequestFactory(org.eclipse.jetty.client.HttpClient httpClient)
Constructor that takes a customized `HttpClient` instance.

Parameters:
  `httpClient` - the

## Method Details

### setConnectTimeout

public void setConnectTimeout(int connectTimeout)
Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.

Default is 5 seconds.

### setConnectTimeout

public void setConnectTimeout(Duration connectTimeout)
Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.

Default is 5 seconds.

### setReadTimeout

public void setReadTimeout(long readTimeout)
Set the underlying read timeout in milliseconds.

Default is 10 seconds.

### setReadTimeout

public void setReadTimeout(Duration readTimeout)
Set the underlying read timeout as `Duration`.

Default is 10 seconds.

### afterPropertiesSet

public void afterPropertiesSet() throws Exception

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Throws:
  `Exception`

### destroy

public void destroy() throws Exception

Specified by:
  `destroy` in interface `org.springframework.beans.factory.DisposableBean`
Throws:
  `Exception`

### createRequest

public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException
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