I have updated the patch on my GitHub repository after some discussion on 
IRC with Anssi. The patch applies on master again now, it consumes 
generator content on access instead of on assignment, and raises a 
PendingDeprecationWarning if you create an HttpResponse with 
stream_content=True and then you try to access response.content. This 
should alert people to the fact that they have explicitly asked for a 
streaming response, but some piece of code somewhere has broken the ability 
to stream the response by accessing it's content directly.

So the end result should be that we fix the buggy response.content != 
response.content behaviour, we preserve the behaviour of existing responses 
and middleware when a generator is passed as content (stream if nothing 
accesses content directly, otherwise don't stream but still execute 
middleware), and either stream or don't stream but issue a warning when 
streaming is explicitly requested.

In 1.7 we could raise a loud exception when stream_content=True and 
response.content is accessed directly. Middleware can do nothing if they 
don't care about or need to worry about streaming responses. If they are 
capable of functioning with a streaming response, they can check 
response.stream_content and wrap the content generator with 
`response.content = wrap(response)`.

Cheers.
Tai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/PFXTllthoTkJ.
To post to this group, send email to django-developers@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.

Reply via email to