2

I need to use Spring reactive WebClient without default chunked encoding mode, which is "enforced" by underlying HttpClient and Netty based stack. Unfortunately the server I need to communicate with does not support this mode, even thou it supports rest of the HTTP 1.1 specs.

I know there is an option to set Content-Length header manually, but that requires you to operate with some DataBuffer like structure and I would like to use as much of the provided support (BodyInserters, Multipart support etc...). After some digging I found something similar is used at HttpClientConfiguration level for GET and HEAD requests, which are buffered in advance. I would like to implement something similar to this, but I am not sure at which level (if it is even possible) best to do so. Ideally I would like to implement some middleware which would only buffer incoming body data until upstream completes and then set Content-Length for downstream. I am not concerned about memory usage.

B.Gen.Jack.O.Neill
  • 8,169
  • 12
  • 51
  • 79
  • If anyone faces similar issue, I bypassed it by creating message body synchronously (still much faster than HTTP transfer, so no extra blocking is introduced) using RestTemplate HttpMessageConverters, therefore I don´t need additional custom logic for different body types and than using WebClient with Content-Length set. This way I can keep all additional logic implemented as ExchangeFilterFunction and don´t need extra threads if using some sync client. – B.Gen.Jack.O.Neill Feb 21 '20 at 09:29

0 Answers0