Closed
Description
Sergey Galkin opened SPR-16989 and commented
I'm sending lots of http request with notifications to other system. I expected small acknowledgment in response (less than 1 KB), but from time to time one of this system start to return huge responses (several MB), which provide no value to me and only consume resources.
For such cases it will be handy if I will be able to configure WebClient to read only limited amount of data from response and keep using bodyToMono method:
retrieve(1024).bodyToMono()
Currently we to replaced bodyToMono
with custom extractor as a workaround.
...
.exchange()
.flatMap(response -> response
.body((t, m) -> t
.getBody()
.takeUntil(buffer -> byteCounter.addAndGet(buffer.readableByteCount()) > logLimit))
.collect(...)
Affects: 5.0.7
Issue Links:
- DataBufferUtils#takeUntilByteCount checks one extra buffer but does not release it [SPR-17118] #21655 DataBufferUtils#takeUntilByteCount checks one extra buffer but does not release it
- DataBufferUtils#join could leak buffers in case of error from the source [SPR-17025] #21563 DataBufferUtils#join could leak buffers in case of error from the source
Referenced from: commits aec9826