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:
-
Constructor Summary
ConstructorDescriptionDefault constructor that creates a new instance ofHttpClient
.JettyClientHttpRequestFactory
(org.eclipse.jetty.client.HttpClient httpClient) Constructor that takes a customizedHttpClient
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createRequest
(URI uri, HttpMethod httpMethod) Create a newClientHttpRequest
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 asDuration
.
-
Constructor Details
-
JettyClientHttpRequestFactory
public JettyClientHttpRequestFactory()Default constructor that creates a new instance ofHttpClient
. -
JettyClientHttpRequestFactory
public JettyClientHttpRequestFactory(org.eclipse.jetty.client.HttpClient httpClient) Constructor that takes a customizedHttpClient
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
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
Set the underlying read timeout asDuration
.Default is 10 seconds.
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-
createRequest
Description copied from interface:ClientHttpRequestFactory
Create a newClientHttpRequest
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 interfaceClientHttpRequestFactory
- Parameters:
uri
- the URI to create a request forhttpMethod
- the HTTP method to execute- Returns:
- the created request
- Throws:
IOException
- in case of I/O errors
-