类 OkHttpClientHttpRequestFactory
- java.lang.Object
- org.springframework.http.client.OkHttpClientHttpRequestFactory
public class OkHttpClientHttpRequestFactory extends Object implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory, DisposableBean
ClientHttpRequestFactoryimplementation that uses OkHttp 2.x to create requests.- 从以下版本开始:
- 4.2
- 作者:
- Luciano Leggieri, Arjen Poutsma
- 另请参阅:
OkHttp3ClientHttpRequestFactory
构造器概要
构造器 构造器 说明 OkHttpClientHttpRequestFactory()Create a factory with a defaultOkHttpClientinstance.OkHttpClientHttpRequestFactory(com.squareup.okhttp.OkHttpClient client)Create a factory with the givenOkHttpClientinstance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 AsyncClientHttpRequestcreateAsyncRequest(URI uri, HttpMethod httpMethod)Create a new asynchronousAsyncClientHttpRequestfor the specified URI and HTTP method.ClientHttpRequestcreateRequest(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)Sets the underlying connect timeout in milliseconds.voidsetReadTimeout(int readTimeout)Sets the underlying read timeout in milliseconds.voidsetWriteTimeout(int writeTimeout)Sets the underlying write timeout in milliseconds.
构造器详细资料
OkHttpClientHttpRequestFactory
public OkHttpClientHttpRequestFactory()
Create a factory with a defaultOkHttpClientinstance.
OkHttpClientHttpRequestFactory
public OkHttpClientHttpRequestFactory(com.squareup.okhttp.OkHttpClient client)
Create a factory with the givenOkHttpClientinstance.- 参数:
client- the client to use
方法详细资料
setReadTimeout
public void setReadTimeout(int readTimeout)
Sets the underlying read timeout in milliseconds. A value of 0 specifies an infinite timeout.- 另请参阅:
OkHttpClient.setReadTimeout(long, TimeUnit)
setWriteTimeout
public void setWriteTimeout(int writeTimeout)
Sets the underlying write timeout in milliseconds. A value of 0 specifies an infinite timeout.- 另请参阅:
OkHttpClient.setWriteTimeout(long, TimeUnit)
setConnectTimeout
public void setConnectTimeout(int connectTimeout)
Sets the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.- 另请参阅:
OkHttpClient.setConnectTimeout(long, TimeUnit)
createRequest
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod)
从接口复制的说明:ClientHttpRequestFactoryCreate a newClientHttpRequestfor 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)
从接口复制的说明:AsyncClientHttpRequestFactoryCreate a new asynchronousAsyncClientHttpRequestfor 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
从接口复制的说明:DisposableBeanInvoked by the containingBeanFactoryon destruction of a bean.- 指定者:
destroy在接口中DisposableBean- 抛出:
IOException