diff --git a/channels/handler.py b/channels/handler.py index 15c8d13..7227a24 100644 --- a/channels/handler.py +++ b/channels/handler.py @@ -11,6 +11,7 @@ from django import http from django.core import signals from django.core.handlers import base from django.core.urlresolvers import set_script_prefix +from django.http import FileResponse from django.utils import six from django.utils.functional import cached_property @@ -184,6 +185,9 @@ class AsgiHandler(base.BaseHandler): else: try: response = self.get_response(request) + # Fix chunk size on file responses + if isinstance(response, FileResponse): + response.block_size = 1024 * 512 except AsgiRequest.ResponseLater: # The view has promised something else # will send a response at a later time diff --git a/channels/staticfiles.py b/channels/staticfiles.py index 153226d..8169be8 100644 --- a/channels/staticfiles.py +++ b/channels/staticfiles.py @@ -49,10 +49,7 @@ class StaticFilesHandler(AsgiHandler): if self._should_handle(request.path): try: - response = self.serve(request) - # Increase FileResponse block sizes so they're not super slow - response.block_size = 1024 * 256 - return response + return self.serve(request) except Http404 as e: if settings.DEBUG: from django.views import debug