Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"body not consumed" error on GET request with content-length=0 #2915

Closed
Ivan-Roger opened this issue Feb 12, 2024 · 1 comment
Closed

"body not consumed" error on GET request with content-length=0 #2915

Ivan-Roger opened this issue Feb 12, 2024 · 1 comment

Comments

@Ivan-Roger
Copy link

Ivan-Roger commented Feb 12, 2024

The default http check from HAProxy v2.4.22 performs a request that looks like this :

GET /health HTTP/1.0
content-length: 0

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 a GET 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 of 0 for a request that isn't expecting a payload) the error could be silently ignored (do not log the body not consumed message)

The haproxy issue has since been adressed (haproxy/haproxy#2026)

Originally posted in #2685 (comment)

@ahopkins
Copy link
Member

ahopkins commented Apr 1, 2024

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.

source

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.

source

This can be ignored on Sanic's side by allowing it to consume the body.

https://sanic.dev/en/guide/basics/routing.md#http-methods

image

@ahopkins ahopkins closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants