You can add a BufferingClientHttpRequestFactory wrapper around any request factory, but it forces you to create the underlying request factory, and you may not want to do that. For example, you might want to add request and response content logging, but not interfere with anything else.
Another issue is that the InterceptingClientHttpRequestFactory also buffers the request content. It is applied internally whenever interceptors are added. So if you want both buffering and interceptors, you end up with InterceptingClientHttpRequestFactory and BufferingClientHttpRequestFactory which duplicates request body buffering and copying.
We can make buffering easy to enable through the RestClient.Builder, and then support it as an internal matter just like we do for interceptors. This would allow us to ensure the request body is buffered efficiently once.
It should be possible to still decide on a per-request basis whether to buffer through some predicate or callback configured at the builder level.
You can add a
BufferingClientHttpRequestFactory
wrapper around any request factory, but it forces you to create the underlying request factory, and you may not want to do that. For example, you might want to add request and response content logging, but not interfere with anything else.Another issue is that the
InterceptingClientHttpRequestFactory
also buffers the request content. It is applied internally whenever interceptors are added. So if you want both buffering and interceptors, you end up withInterceptingClientHttpRequestFactory
andBufferingClientHttpRequestFactory
which duplicates request body buffering and copying.We can make buffering easy to enable through the
RestClient.Builder
, and then support it as an internal matter just like we do for interceptors. This would allow us to ensure the request body is buffered efficiently once.It should be possible to still decide on a per-request basis whether to buffer through some predicate or callback configured at the builder level.