public class OkHttp3ClientHttpRequestFactory extends Object implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory, DisposableBean
ClientHttpRequestFactory implementation that uses
OkHttp 3.x to create requests.| Constructor and Description |
|---|
OkHttp3ClientHttpRequestFactory()
Create a factory with a default
OkHttpClient instance. |
OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient client)
Create a factory with the given
OkHttpClient instance. |
| Modifier and Type | Method and Description |
|---|---|
AsyncClientHttpRequest |
createAsyncRequest(URI uri,
HttpMethod httpMethod)
Create a new asynchronous
AsyncClientHttpRequest for the specified URI
and HTTP method. |
ClientHttpRequest |
createRequest(URI uri,
HttpMethod httpMethod)
Create a new
ClientHttpRequest for the specified URI and HTTP method. |
void |
destroy()
Invoked by the containing
BeanFactory on destruction of a bean. |
void |
setConnectTimeout(int connectTimeout)
Set the underlying connect timeout in milliseconds.
|
void |
setReadTimeout(int readTimeout)
Set the underlying read timeout in milliseconds.
|
void |
setWriteTimeout(int writeTimeout)
Set the underlying write timeout in milliseconds.
|
public OkHttp3ClientHttpRequestFactory()
OkHttpClient instance.public OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient client)
OkHttpClient instance.client - the client to usepublic void setReadTimeout(int readTimeout)
public void setWriteTimeout(int writeTimeout)
public void setConnectTimeout(int connectTimeout)
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod)
ClientHttpRequestFactoryClientHttpRequest for the specified URI and HTTP method.
The returned request can be written to, and then executed by calling
ClientHttpRequest.execute().
createRequest in interface ClientHttpRequestFactoryuri - the URI to create a request forhttpMethod - the HTTP method to executepublic AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod)
AsyncClientHttpRequestFactoryAsyncClientHttpRequest for the specified URI
and HTTP method.
The returned request can be written to, and then executed by calling
AsyncClientHttpRequest.executeAsync().
createAsyncRequest in interface AsyncClientHttpRequestFactoryuri - the URI to create a request forhttpMethod - the HTTP method to executepublic void destroy()
throws IOException
DisposableBeanBeanFactory on destruction of a bean.destroy in interface DisposableBeanIOException