Class JdkClientHttpRequestFactory
java.lang.Object
org.springframework.http.client.JdkClientHttpRequestFactory
- All Implemented Interfaces:
ClientHttpRequestFactory
ClientHttpRequestFactory implementation based on the Java HttpClient.- Since:
- 6.1
- Author:
- Marten Deinum, Arjen Poutsma
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of theJdkClientHttpRequestFactorywith a defaultHttpClient.JdkClientHttpRequestFactory(HttpClient httpClient) Create a new instance of theJdkClientHttpRequestFactorybased on the givenHttpClient.JdkClientHttpRequestFactory(HttpClient httpClient, Executor executor) Create a new instance of theJdkClientHttpRequestFactorybased on the givenHttpClientandExecutor. -
Method Summary
Modifier and TypeMethodDescriptioncreateRequest(URI uri, HttpMethod httpMethod) Create a newClientHttpRequestfor the specified URI and HTTP method.voidenableCompression(boolean enable) Set whether support for uncompressing "gzip" and "deflate" HTTP responses is enabled.voidsetReadTimeout(int readTimeout) Set the underlyingHttpClient's read timeout (in milliseconds).voidsetReadTimeout(Duration readTimeout) Set the underlyingHttpClient's read timeout as aDuration.
-
Constructor Details
-
JdkClientHttpRequestFactory
public JdkClientHttpRequestFactory()Create a new instance of theJdkClientHttpRequestFactorywith a defaultHttpClient. -
JdkClientHttpRequestFactory
Create a new instance of theJdkClientHttpRequestFactorybased on the givenHttpClient.- Parameters:
httpClient- the client to base on
-
JdkClientHttpRequestFactory
Create a new instance of theJdkClientHttpRequestFactorybased on the givenHttpClientandExecutor.- Parameters:
httpClient- the client to base onexecutor- the executor to use for blocking write operations
-
-
Method Details
-
setReadTimeout
public void setReadTimeout(int readTimeout) Set the underlyingHttpClient's read timeout (in milliseconds). A timeout value of 0 specifies an infinite timeout.Default is the system's default timeout.
- See Also:
-
setReadTimeout
Set the underlyingHttpClient's read timeout as aDuration.Default is the system's default timeout.
- See Also:
-
enableCompression
public void enableCompression(boolean enable) Set whether support for uncompressing "gzip" and "deflate" HTTP responses is enabled.- Since:
- 7.0
-
createRequest
Description copied from interface:ClientHttpRequestFactoryCreate a newClientHttpRequestfor the specified URI and HTTP method.The returned request can be written to, and then executed by calling
ClientHttpRequest.execute().- Specified by:
createRequestin 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
-