-
Notifications
You must be signed in to change notification settings - Fork 269
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
HTTP 1.x chunked transfer encoding + content length header conflict #371
Comments
Hi @eelkevdbos — thanks for the report, yes:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding#directives |
@carltongibson, I was thinking about writing a patch that checks for the above condition in http_protocol.py#L151 removing the content-length header if a chunked transfer encoding is found as well. Do you think the above mentioned location is suitable for this kind of operation? |
Hey @eelkevdbos — Grrr. 😬 Looking at the way gunicorn handles this if the client sets guicorn takes it as its responsibility to set the 🤔 |
But yes 😀 that would be an appropriate place to add handling, once we're clear on the best way forward. |
RFC 9112, section 6.2 says this:
Therefore, Daphne is obligated to either remove the |
@kenballus The latter option there is what gunicorn is doing right? Would you fancy picking this one up? |
Hello @carltongibson @kenballus! I arrived to this issue while trying to triage Django ticket 35289, which is about "Chunked transfer encoding is not handled correctly by MultiPartParser". In that ticket, the reporter says that the obsoleted (RFC 2616 section 4.4) says the same thing (
Would you understand how the paragraph above plays with what was said in the previous comment? |
@nessita Nice find thank you. Without digging too much, I think we still need to adjust the behaviour here to mirror that of other servers (gunicorn/uvicorn/&co) I think @eelkevdbos's:
... is likely right. (Assuming the application already processed the response, which is why it set the header.) |
My application serves (large) binary files. It serves those files with the following headers:
When the request is handled over HTTP 2.x, this does not result in any issues. However, upon fallback to HTTP 1.x, this results in an error. The issue can be replicated by executing
curl -X GET http://host/file.db
, forcing the fallback by using HTTP 1.x.The following error is returned:
Some web servers, like Uvicorn for example, solve this by ignoring the content-length header when any transfer-encoding is set. Would it be desirable to replicate this behavior in Daphne?
Daphne version: 3.0.2
Python 3.9.5
The text was updated successfully, but these errors were encountered: