Package org.springframework.http.client
Class OkHttp3ClientHttpRequestFactory
java.lang.Object
org.springframework.http.client.OkHttp3ClientHttpRequestFactory
- All Implemented Interfaces:
- DisposableBean,- ClientHttpRequestFactory
public class OkHttp3ClientHttpRequestFactory
extends Object
implements ClientHttpRequestFactory, DisposableBean
ClientHttpRequestFactory implementation that uses
 OkHttp 3.x to create requests.- Since:
- 4.3
- Author:
- Luciano Leggieri, Arjen Poutsma, Roy Clarkson
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a factory with a defaultOkHttpClientinstance.OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient client) Create a factory with the givenOkHttpClientinstance.
- 
Method SummaryModifier and TypeMethodDescriptioncreateRequest(URI uri, HttpMethod httpMethod) Create a newClientHttpRequestfor the specified URI and HTTP method.voiddestroy()Invoked by the containingBeanFactoryon destruction of a bean.voidsetConnectTimeout(int connectTimeout) Set the underlying connect timeout in milliseconds.voidsetReadTimeout(int readTimeout) Set the underlying read timeout in milliseconds.voidsetWriteTimeout(int writeTimeout) Set the underlying write timeout in milliseconds.
- 
Constructor Details- 
OkHttp3ClientHttpRequestFactorypublic OkHttp3ClientHttpRequestFactory()Create a factory with a defaultOkHttpClientinstance.
- 
OkHttp3ClientHttpRequestFactorypublic OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient client) Create a factory with the givenOkHttpClientinstance.- Parameters:
- client- the client to use
 
 
- 
- 
Method Details- 
setReadTimeoutpublic void setReadTimeout(int readTimeout) Set the underlying read timeout in milliseconds. A value of 0 specifies an infinite timeout.
- 
setWriteTimeoutpublic void setWriteTimeout(int writeTimeout) Set the underlying write timeout in milliseconds. A value of 0 specifies an infinite timeout.
- 
setConnectTimeoutpublic void setConnectTimeout(int connectTimeout) Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.
- 
createRequestDescription 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 interface- ClientHttpRequestFactory
- Parameters:
- uri- the URI to create a request for
- httpMethod- the HTTP method to execute
- Returns:
- the created request
 
- 
destroyDescription copied from interface:DisposableBeanInvoked by the containingBeanFactoryon destruction of a bean.- Specified by:
- destroyin interface- DisposableBean
- Throws:
- IOException
 
 
-