See also #7581, which has a patch that I have been using in my local Django branch for over a year without issue. My use case is that I need to generate large amounts of data in CSV format and stream the response to avoid timeouts. I wouldn't mind `HttpResponse` consuming `content` immediately if we had a `Http StreamingResponse` or similar subclass, but the issue I found after discussion with Malcolm and Ivan Sagalaev and ccahoon who worked on the http-wsgi-improvements branch relates to middleware needing to be aware of when they should or should not consume the content in a response, when they should replace the content or generator in a response, or when they should be skipped entirely.
Here's my suggestion taken from a recent comment in #7581: I suggest that we simply add an attribute `HttpResponse.disabled_middleware` (list or tuple). Any installed middleware specified there should be bypassed when applying response middleware. Django could then ship with an `HttpStreamingResponse` class that disables any included middleware that is known not to work with generator content, and this could easily be subclassed and updated by users who need to disable any 3rd party middleware to create a streaming response. Cheers. Tai. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.