Top Description Constructors Methods
org.springframework.http.client

public Class BufferingClientHttpRequestFactory

extends AbstractClientHttpRequestFactoryWrapper
Class Inheritance
Imports
java.io.IOException, java.net.URI, org.springframework.http.HttpMethod

Wrapper for a ClientHttpRequestFactory that buffers all outgoing and incoming streams in memory.

Using this wrapper allows for multiple reads of the response body.

Author
Arjen Poutsma
Since
3.1

Constructor Summary

AccessConstructor and Description
public
BufferingClientHttpRequestFactory(ClientHttpRequestFactory
the target request factory to wrap
requestFactory
)

Create a buffering wrapper for the given ClientHttpRequestFactory.

Method Summary

Modifier and TypeMethod and Description
protected ClientHttpRequest
createRequest(URI
the URI to create a request for
uri
,
HttpMethod
the HTTP method to execute
httpMethod
,
ClientHttpRequestFactory
the wrapped request factory
requestFactory
)

Implements abstract org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper.createRequest.

Create a new ClientHttpRequest for the specified URI and HTTP method by using the passed-on request factory.

protected boolean

Returns:

true if the exchange should be buffered; false otherwise
shouldBuffer
(URI
the URI
uri
,
HttpMethod
the method
httpMethod
)

Indicates whether the request/response exchange for the given URI and method should be buffered in memory.

Inherited from org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper:
createRequestgetDelegate

Constructor Detail

BufferingClientHttpRequestFactoryback to summary
public BufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory)

Create a buffering wrapper for the given ClientHttpRequestFactory.

Parameters
requestFactory:ClientHttpRequestFactory

the target request factory to wrap

Method Detail

createRequestback to summary
protected ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod, ClientHttpRequestFactory requestFactory) throws IOException

Implements abstract org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper.createRequest.

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

Create a new ClientHttpRequest for the specified URI and HTTP method by using the passed-on request factory.

Called from createRequest(URI, HttpMethod).

Parameters
uri:URI

the URI to create a request for

httpMethod:HttpMethod

the HTTP method to execute

requestFactory:ClientHttpRequestFactory

the wrapped request factory

Returns:ClientHttpRequest

the created request

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
shouldBufferback to summary
protected boolean shouldBuffer(URI uri, HttpMethod httpMethod)

Indicates whether the request/response exchange for the given URI and method should be buffered in memory.

The default implementation returns true for all URIs and methods. Subclasses can override this method to change this behavior.

Parameters
uri:URI

the URI

httpMethod:HttpMethod

the method

Returns:boolean

true if the exchange should be buffered; false otherwise