diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-07-31 13:33:01 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-31 13:33:01 +0200 |
| commit | eea0bf7bd58cda4618ecc10133f0ad09effe1a2e (patch) | |
| tree | dc4ec0f11ebf0898ebc120f57b874de246c20f90 | |
| parent | 5f24e7158e1d5a7e40fa0ae270639f6a171bb18e (diff) | |
Refs #30669 -- Removed incorrect branch in ASGIHander.read_body().
None is not valid for settings.FILE_UPLOAD_MAX_MEMORY_SIZE.
Always use SpooledTemporaryFile.
| -rw-r--r-- | django/core/handlers/asgi.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/django/core/handlers/asgi.py b/django/core/handlers/asgi.py index bc9c2d76df..00f00ec1e5 100644 --- a/django/core/handlers/asgi.py +++ b/django/core/handlers/asgi.py @@ -3,7 +3,6 @@ import logging import sys import tempfile import traceback -from io import BytesIO from asgiref.sync import sync_to_async @@ -175,12 +174,8 @@ class ASGIHandler(base.BaseHandler): async def read_body(self, receive): """Reads a HTTP body from an ASGI connection.""" - # Use the tempfile that auto rolls-over to a disk file as it fills up, - # if a maximum in-memory size is set. Otherwise use a BytesIO object. - if settings.FILE_UPLOAD_MAX_MEMORY_SIZE is None: - body_file = BytesIO() - else: - body_file = tempfile.SpooledTemporaryFile(max_size=settings.FILE_UPLOAD_MAX_MEMORY_SIZE, mode='w+b') + # Use the tempfile that auto rolls-over to a disk file as it fills up. + body_file = tempfile.SpooledTemporaryFile(max_size=settings.FILE_UPLOAD_MAX_MEMORY_SIZE, mode='w+b') while True: message = await receive() if message['type'] == 'http.disconnect': |
