Closed Ivan-Roger closed 6 months ago
Hmm, I am not sure I agree that it is Sanic's responsibility for ignoring that.
A user agent SHOULD NOT send a Content-Length header field when the request message does not contain content and the method semantics do not anticipate such data.
A client SHOULD NOT generate content in a GET request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported.
This can be ignored on Sanic's side by allowing it to consume the body.
The default http check from HAProxy v2.4.22 performs a request that looks like this :
When presented with such a request sanic logs an error in the form of :
[sanic.error] <Request: GET /health> body not consumed.
The issue here is with the
content-length
header being sent for aGET
request that should not contain a payload.Even though the value is
0
Sanic seems to believe the request has a payload.The RFCs are not clear as to whether it is actually allowed or forbidden to send this header for
GET
requests :Nevertheless I believe that in this specific case (A
Content-Length
header with a value of0
for a request that isn't expecting a payload) the error could be silently ignored (do not log thebody not consumed
message)The haproxy issue has since been adressed (https://github.com/haproxy/haproxy/issues/2026)
Originally posted in https://github.com/sanic-org/sanic/issues/2685#issuecomment-1939166018