In WebFilter, how can I identify whether an inbound HTTP request has a body or not? I am aware of the Content-Length header presence check, but it's a hack at the best. Besides, it will not catch all the cases (some of the clients are sending the body without the Content-Length header).
Note: I just need to identify whether the body is there or not, reading body is a whole different question!
The server is Netty, if that helps.
In WebFlux you can use the 'HttpMessageReader' interface to determine whether an inbound HTTP request has a body or not. This interface is used to read the body of a request, so you can check if there is a registered 'HttpMessageReader' that supports the 'Content-Type' of the request.
If there is such a reader, then the request has a body; if not, then the request doesn't have a body.
Sample code: