类 OkHttp3ClientHttpRequestFactory
- java.lang.Object
- org.springframework.http.client.OkHttp3ClientHttpRequestFactory
public class OkHttp3ClientHttpRequestFactory extends Object implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory, DisposableBean
ClientHttpRequestFactory
implementation that uses OkHttp 3.x to create requests.- 从以下版本开始:
- 4.3
- 作者:
- Luciano Leggieri, Arjen Poutsma, Roy Clarkson
构造器概要
构造器 构造器 说明 OkHttp3ClientHttpRequestFactory()
Create a factory with a defaultOkHttpClient
instance.OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient client)
Create a factory with the givenOkHttpClient
instance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 AsyncClientHttpRequest
createAsyncRequest(URI uri, HttpMethod httpMethod)
Create a new asynchronousAsyncClientHttpRequest
for the specified URI and HTTP method.ClientHttpRequest
createRequest(URI uri, HttpMethod httpMethod)
Create a newClientHttpRequest
for the specified URI and HTTP method.void
destroy()
Invoked by the containingBeanFactory
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.
构造器详细资料
OkHttp3ClientHttpRequestFactory
public OkHttp3ClientHttpRequestFactory()
Create a factory with a defaultOkHttpClient
instance.
OkHttp3ClientHttpRequestFactory
public OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient client)
Create a factory with the givenOkHttpClient
instance.- 参数:
client
- the client to use
方法详细资料
setReadTimeout
public void setReadTimeout(int readTimeout)
Set the underlying read timeout in milliseconds. A value of 0 specifies an infinite timeout.
setWriteTimeout
public void setWriteTimeout(int writeTimeout)
Set the underlying write timeout in milliseconds. A value of 0 specifies an infinite timeout.
setConnectTimeout
public void setConnectTimeout(int connectTimeout)
Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.
createRequest
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod)
从接口复制的说明: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()
.- 指定者:
createRequest
在接口中ClientHttpRequestFactory
- 参数:
uri
- the URI to create a request forhttpMethod
- the HTTP method to execute- 返回:
- the created request
createAsyncRequest
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod)
从接口复制的说明:AsyncClientHttpRequestFactory
Create a new asynchronousAsyncClientHttpRequest
for the specified URI and HTTP method.The returned request can be written to, and then executed by calling
AsyncClientHttpRequest.executeAsync()
.- 指定者:
createAsyncRequest
在接口中AsyncClientHttpRequestFactory
- 参数:
uri
- the URI to create a request forhttpMethod
- the HTTP method to execute- 返回:
- the created request
destroy
public void destroy() throws IOException
从接口复制的说明:DisposableBean
Invoked by the containingBeanFactory
on destruction of a bean.- 指定者:
destroy
在接口中DisposableBean
- 抛出:
IOException