reactor-netty
reactor-netty copied to clipboard
Provide API to ensure client response is drained
This is how consumeAndCancel is done in the WebClient
for example. This isn't too bad but anything using HttpClient
would need something similar and arguably Reactor Netty should have official API to encourage good behavior.
Then it gets more tricky if you want to do the same from a place where you don't know if the body has been consumed or not. You've to do something more like this where you try to consume and if an error occurs, suppress it expecting it's probably because the body has been read. This is fragile and could lead to issues like https://github.com/reactor/reactor-netty/issues/503 that are very tricky to debug.
It would be useful if such an API provided options for how to drain, e.g. try to consume and if anything comes then cancel (like above), or perhaps allow reading up to a certain amount of data and/or timeout and then cancel.
Would be useful for spring Cloud Gateway