spring-framework / org.springframework.http.client / SimpleClientHttpRequestFactory

SimpleClientHttpRequestFactory

open class SimpleClientHttpRequestFactory : ClientHttpRequestFactory, AsyncClientHttpRequestFactory

ClientHttpRequestFactory implementation that uses standard JDK facilities.

Author
Arjen Poutsma

Author
Juergen Hoeller

Since
3.0

See Also
java.net.HttpURLConnectionHttpComponentsClientHttpRequestFactory

Constructors

<init>

SimpleClientHttpRequestFactory()

ClientHttpRequestFactory implementation that uses standard JDK facilities.

Functions

createAsyncRequest

open fun createAsyncRequest(uri: URI, httpMethod: HttpMethod): AsyncClientHttpRequest

{@inheritDoc}

Setting the taskExecutor property is required before calling this method.

createRequest

open fun createRequest(uri: URI, httpMethod: HttpMethod): ClientHttpRequest

setBufferRequestBody

open fun setBufferRequestBody(bufferRequestBody: Boolean): Unit

Indicate whether this request factory should buffer the request body internally.

Default is true. When sending large amounts of data via POST or PUT, it is recommended to change this property to false, so as not to run out of memory. This will result in a ClientHttpRequest that either streams directly to the underlying HttpURLConnection (if the Content-Length is known in advance), or that will use "Chunked transfer encoding" (if the Content-Length is not known in advance).

setChunkSize

open fun setChunkSize(chunkSize: Int): Unit

Set the number of bytes to write in each chunk when not buffering request bodies locally.

Note that this parameter is only used when bufferRequestBody is set to false, and the Content-Length is not known in advance.

setConnectTimeout

open fun setConnectTimeout(connectTimeout: Int): Unit

Set the underlying URLConnection's connect timeout (in milliseconds). A timeout value of 0 specifies an infinite timeout.

Default is the system's default timeout.

setOutputStreaming

open fun setOutputStreaming(outputStreaming: Boolean): Unit

Set if the underlying URLConnection can be set to 'output streaming' mode. Default is true.

When output streaming is enabled, authentication and redirection cannot be handled automatically. If output streaming is disabled, the HttpURLConnection#setFixedLengthStreamingMode and HttpURLConnection#setChunkedStreamingMode methods of the underlying connection will never be called.

setProxy

open fun setProxy(proxy: Proxy): Unit

Set the Proxy to use for this request factory.

setReadTimeout

open fun setReadTimeout(readTimeout: Int): Unit

Set the underlying URLConnection's read timeout (in milliseconds). A timeout value of 0 specifies an infinite timeout.

Default is the system's default timeout.

setTaskExecutor

open fun setTaskExecutor(taskExecutor: AsyncListenableTaskExecutor): Unit

Set the task executor for this request factory. Setting this property is required for creating asynchronous requests.