-
Notifications
You must be signed in to change notification settings - Fork 270
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
Requests with Transfer-Encoding: chunked have no content #476
Comments
Can you check that the |
The data seems to be there:
Added this line: def index(request):
print("body", request.body) |
OK, so there's some weirdness as to why it's not getting out of Django's |
Yes, probably. I tried it with something more managable:
I'm on Django 4.2.1 and Daphne 4.0.0 by the way. |
Do you think this is a django issue? Should I raise it there? |
First, can you reduce it to say exactly what's going on? (It's be closed as needs info without a reproduce) |
I cannot say what exactly is going on. The above code is enough to reproduce the issue, but I'm happy with providing a full project for this if needed? |
Hi @tfeldmann -- thanks for the bump. No need for a project... the script looks fine. I haven't had a chance to look at this in a debugger, but will try and do so over the next period. |
Of course, waitress is a WSGI server. Q: do we get the same issue with hypercorn/uvicorn? |
I found this in the spec (https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope):
I don't know how hypercorn / uvicorn handle this. |
Yes... 🤔 The interesting one was that the body makes it (as far as we're aware). (I need time to sit down with the debugger to be able to say more, but that's the question I'm asking first.) |
I think this is a Django bug and I opened a ticket here. Transfer-encoding chunked should not have a content length per the HTTP spec but Django only uses the content-length for determining if uploaded files should be processed. There is a conditional in Django that gives up on uploaded files if the content-length is 0. You can make a middleware to spoof the content length to 1 if the if request.headers["Transfer-Encoding"] == "chunked" and "CONTENT_LENGTH" not in request.META:
request.META["CONTENT_LENGTH"] = "1" and everything works correctly. You'll also want to set your |
Closing this in favour of the Django ticket. Happy to reopen if there's something else Daphne needs to do here. |
@agronick do you have a patch example that works for you? Is there a patch to django code yet? |
I guess I'm a bit confused by now.
According to the ASGI spec the server should handle (dechunk?) incoming requests.
So I've written a small django app with this view:
Starting daphne with
daphne myapp.asgi:application -p 8080
and execute a curl request withResults in:
Doing the same in waitress (which dechunks the request) results in:
What am I doing wrong here?
The text was updated successfully, but these errors were encountered: