Top Description Fields Constructors Methods
org.springframework.http.client

public Class OkHttp3ClientHttpRequestFactory

extends Object
implements ClientHttpRequestFactory, DisposableBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.DisposableBean, org.springframework.http.client.ClientHttpRequestFactory
Annotations
@Deprecated
since:6.1
forRemoval:true
Imports
java.io.IOException, java.net.URI, java.time.Duration, java.util.concurrent.TimeUnit, okhttp3.Cache, okhttp3.OkHttpClient, org.springframework.beans.factory.DisposableBean, org.springframework.http.HttpMethod, org.springframework.util.Assert

Deprecated

for removal since 6.1.

since 6.1, in favor of other ClientHttpRequestFactory implementations; scheduled for removal in 6.2

ClientHttpRequestFactory implementation that uses OkHttp 3.x to create requests.
Authors
Luciano Leggieri, Arjen Poutsma, Roy Clarkson
Since
4.3

Field Summary

Modifier and TypeField and Description
private okhttp3.OkHttpClient
private final boolean

Constructor Summary

AccessConstructor and Description
public
OkHttp3ClientHttpRequestFactory()

Create a factory with a default OkHttpClient instance.

public
OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient
the client to use
client
)

Create a factory with the given OkHttpClient instance.

Method Summary

Modifier and TypeMethod and Description
public ClientHttpRequest
createRequest(URI
the URI to create a request for
uri
,
HttpMethod
the HTTP method to execute
httpMethod
)

Implements org.springframework.http.client.ClientHttpRequestFactory.createRequest.

Create a new ClientHttpRequest for the specified URI and HTTP method.
public void
destroy()

Implements org.springframework.beans.factory.DisposableBean.destroy.

Invoked by the containing BeanFactory on destruction of a bean.
public void
setConnectTimeout(int connectTimeout)

Set the underlying connect timeout in milliseconds.

public void
setConnectTimeout(Duration connectTimeout)

Set the underlying connect timeout in milliseconds.

public void
setReadTimeout(int readTimeout)

Set the underlying read timeout in milliseconds.

public void
setReadTimeout(Duration readTimeout)

Set the underlying read timeout in milliseconds.

public void
setWriteTimeout(int writeTimeout)

Set the underlying write timeout in milliseconds.

public void
setWriteTimeout(Duration writeTimeout)

Set the underlying write timeout in milliseconds.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clientback to summary
private okhttp3.OkHttpClient client
defaultClientback to summary
private final boolean defaultClient

Constructor Detail

OkHttp3ClientHttpRequestFactoryback to summary
public OkHttp3ClientHttpRequestFactory()

Create a factory with a default OkHttpClient instance.

OkHttp3ClientHttpRequestFactoryback to summary
public OkHttp3ClientHttpRequestFactory(okhttp3.OkHttpClient client)

Create a factory with the given OkHttpClient instance.

Parameters
client:okhttp3.OkHttpClient

the client to use

Method Detail

createRequestback to summary
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod)

Implements org.springframework.http.client.ClientHttpRequestFactory.createRequest.

Doc from org.springframework.http.client.ClientHttpRequestFactory.createRequest.

Create a new ClientHttpRequest for the specified URI and HTTP method.

The returned request can be written to, and then executed by calling ClientHttpRequest#execute().

Parameters
uri:URI

the URI to create a request for

httpMethod:HttpMethod

the HTTP method to execute

Returns:ClientHttpRequest

the created request

Annotations
@Override
@SuppressWarnings:removal
destroyback to summary
public void destroy() throws IOException

Implements org.springframework.beans.factory.DisposableBean.destroy.

Doc from org.springframework.beans.factory.DisposableBean.destroy.

Invoked by the containing BeanFactory on destruction of a bean.

Annotations
@Override
setConnectTimeoutback to summary
public void setConnectTimeout(int connectTimeout)

Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.

setConnectTimeoutback to summary
public void setConnectTimeout(Duration connectTimeout)

Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.

Since
6.1
setReadTimeoutback to summary
public void setReadTimeout(int readTimeout)

Set the underlying read timeout in milliseconds. A value of 0 specifies an infinite timeout.

setReadTimeoutback to summary
public void setReadTimeout(Duration readTimeout)

Set the underlying read timeout in milliseconds. A value of 0 specifies an infinite timeout.

Since
6.1
setWriteTimeoutback to summary
public void setWriteTimeout(int writeTimeout)

Set the underlying write timeout in milliseconds. A value of 0 specifies an infinite timeout.

setWriteTimeoutback to summary
public void setWriteTimeout(Duration writeTimeout)

Set the underlying write timeout in milliseconds. A value of 0 specifies an infinite timeout.

Since
6.1