Package org.springframework.http.client
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.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.
-
setReadTimeout
Set the underlyingHttpClient's read timeout as aDuration.Default is the system's default timeout.
-
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
-