django/django — pull request #407 by mrmachine (2012-09-29 04:40:02+00:00)
Title: Fixed #7581 -- Add explicit support for streaming responses.

Refactored `HttpResponse` into `HttpResponseBase`, `HttpResponse` and
`HttpStreamingResponse`.

`HttpResponse` exposes a `content` attribute, which is normalised to a
byte string.

`HttpStreamingResponse` exposes a `streaming_content` attribute, which
is normalised to an iterator that yields byte strings.

Bundled middleware that need to access a response's content now
examines the response (looks for a `content` or `streaming_content`
attribute) to determine it's capabilities.

The `django.views.static.serve` view now returns a streaming response,
which is MUCH faster.

The `conditional_content_removal()` function in `django.http.utils`,
which is applied as a "response fix" (compulsory middleware) now
understands streaming responses, and was missing tests that have now
been added.