I would like to avoid having two code paths, one with streaming and one
without, in new middleware. 

If `HttpResponse` followed the the `streaming_content` API as well, when
writing a streaming-aware middleware instead of writing

    if response.streaming:
        response.streaming_content = 
wrap_streaming_content(response.streaming_content)
    else:
        response.content = wrap_content(response.content)

One could write
      
      response.streaming_content = 
wrap_streaming_content(response.streaming_content)

The behavior for `StreamingHttpResponse` would be the same, but 
`HttpResponse`
would consume the iterator assigned to `streaming_content` and store it in
`content`. Since an iterator (`streaming_content`) can be trivially 
converted
to a string (`content`), this would prevent having to write to versions of
`wrap_content`, one for iterators and the other for strings.

-- 
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/-/QSNgS_hd4YcJ.
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