Package org.springframework.http.client
Class BufferingClientHttpRequestFactory
java.lang.Object
org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper
org.springframework.http.client.BufferingClientHttpRequestFactory
- All Implemented Interfaces:
- ClientHttpRequestFactory
ClientHttpRequestFactory that wraps another in order to buffer
 outgoing and incoming content in memory, making it possible to set a
 content-length on the request, and to read the
 response body multiple times.
 Note: as of 7.0, buffering can be enabled through
 RestClient.Builder.bufferContent(BiPredicate)
 and therefore it is not necessary for applications to use this class directly.
- Since:
- 3.1
- Author:
- Arjen Poutsma, Rossen Stoyanchev
- 
Constructor SummaryConstructorsConstructorDescriptionBufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory) Create a buffering wrapper for the givenClientHttpRequestFactory.BufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory, @Nullable BiPredicate<URI, HttpMethod> bufferingPredicate) Constructor variant with an additional predicate to decide whether to buffer the response.
- 
Method SummaryModifier and TypeMethodDescriptionprotected ClientHttpRequestcreateRequest(URI uri, HttpMethod httpMethod, ClientHttpRequestFactory requestFactory) Create a newClientHttpRequestfor the specified URI and HTTP method by using the passed-on request factory.protected booleanshouldBuffer(URI uri, HttpMethod httpMethod) Indicates whether the request/response exchange for the given URI and method should be buffered in memory.Methods inherited from class org.springframework.http.client.AbstractClientHttpRequestFactoryWrappercreateRequest, getDelegate
- 
Constructor Details- 
BufferingClientHttpRequestFactoryCreate a buffering wrapper for the givenClientHttpRequestFactory.- Parameters:
- requestFactory- the target request factory to wrap
 
- 
BufferingClientHttpRequestFactorypublic BufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory, @Nullable BiPredicate<URI, HttpMethod> bufferingPredicate) Constructor variant with an additional predicate to decide whether to buffer the response.- Since:
- 7.0
 
 
- 
- 
Method Details- 
createRequestprotected ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod, ClientHttpRequestFactory requestFactory) throws IOException Description copied from class:AbstractClientHttpRequestFactoryWrapperCreate a newClientHttpRequestfor the specified URI and HTTP method by using the passed-on request factory.Called from AbstractClientHttpRequestFactoryWrapper.createRequest(URI, HttpMethod).- Specified by:
- createRequestin class- AbstractClientHttpRequestFactoryWrapper
- Parameters:
- uri- the URI to create a request for
- httpMethod- the HTTP method to execute
- requestFactory- the wrapped request factory
- Returns:
- the created request
- Throws:
- IOException- in case of I/O errors
 
- 
shouldBufferIndicates whether the request/response exchange for the given URI and method should be buffered in memory.The default implementation returns truefor all URIs and methods. Subclasses can override this method to change this behavior.- Parameters:
- uri- the URI
- httpMethod- the method
- Returns:
- trueif the exchange should be buffered;- falseotherwise
 
 
-