#35592: ASGIHandler fully buffers request before handling it
-------------------------------------+-------------------------------------
Reporter: Klaas van Schelven | Type:
| Uncategorized
Status: new | Component:
| Uncategorized
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
The `ASGIHandler`
[
https://github.com/django/django/blob/86e13843c2ab510fba1de84588efe7fd03555531/django/core/handlers/asgi.py#L170
reads the full request body] before proceeding with actually "doing the
Django thing" (processing the request with a view).
In this aspect the `ASGIHandler` has less support for streaming than the
`WSGIHandler`.
When running Django as a WSGI application, I am able to start reading from
a request (using `request.read(chunk_size)` as it becomes available to my
web server. This enables me to process large requests in a streaming way
(lower latency, support for abort-early). When running Django as an ASGI
application (at least as per the provided `asgi.py`) I am unable to do
this.
This is contrary to my general expectation that things starting with an
'A' should have equal or better support for streaming than things starting
with a 'W'. The following line from the ASGI spec gives credit to that
expectation "ASGI attempts to preserve a simple application interface,
while providing an abstraction that allows for data to be sent and
received at any time"
--
Ticket URL: <
https://code.djangoproject.com/ticket/35592>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.