org.springframework.http.client

## Class BufferingClientHttpRequestFactory

- java.lang.Object
- - org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper
  - - org.springframework.http.client.BufferingClientHttpRequestFactory

- All Implemented Interfaces:
    ClientHttpRequestFactory

      public class BufferingClientHttpRequestFactory
      extends AbstractClientHttpRequestFactoryWrapper

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

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

  Since:
    3.1
  Author:
    Arjen Poutsma

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected ClientHttpRequest` | `createRequest(URI uri, HttpMethod httpMethod, ClientHttpRequestFactory requestFactory)` Create a new `ClientHttpRequest` for the specified URI and HTTP method by using the passed-on request factory.
    `protected boolean` | `shouldBuffer(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.AbstractClientHttpRequestFactoryWrapper

      `createRequest`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BufferingClientHttpRequestFactory

          public BufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory)

  - ### Method Detail

    - #### createRequest

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

      Description copied from class: `AbstractClientHttpRequestFactoryWrapper`
      Create a new `ClientHttpRequest` for the specified URI and HTTP method by using the passed-on request factory.

      Called from `AbstractClientHttpRequestFactoryWrapper.createRequest(URI, HttpMethod)`.

      Specified by:
        `createRequest` in 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

    - #### shouldBuffer

          protected boolean shouldBuffer(URI uri,
                                         HttpMethod httpMethod)

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

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

      Parameters:
        `uri` - the URI
        `httpMethod` - the method
      Returns:
        `true` if the exchange should be buffered; `false` otherwise