Hi Ryan, I don't think what you are suggesting would be necessary. Stream-capable middleware could avoid having to handle both cases by simply wrapping response.content with a new iterator in all cases, if they want to. Non-streaming responses can still be iterated. They just have fewer iterations (as few as one).
The only reason for a stream-capable middleware to access response.content explicitly in this case is for improved efficiency when the user doesn't care about streaming the response. I think GZipping the whole content is probably more efficient than GZipping chunks of it. Cheers. Tai. On Friday, August 24, 2012 2:48:53 AM UTC+10, Ryan Hiebert wrote: > > Rather than requiring stream-capable middleware to check if it is stream > content, and also require them to handle non-stream content separately, can > we have .stream_content return an auto created generator with some sane > automatic divisions (at newlines or every x bytes/characters). This would > allow stream-aware middleware to act as if everything they do is streams, > even if in reality it is not. > > If we don't do this, it seems likely enough that middlewares that are > stream-aware might end up doing this conversion anyway. If that's the case, > moving that work into .stream_content can save them some common boilerplate > code. > > One possible problem with this approach would be that if there are many > middlewares, alternating back and forth between stream aware and stream > unaware, that the overhead might be significant. If it turned out that was > the case, then proper ordering of middlewares would be part of optimizing a > project, if it isn't already. > > Ryan > > -- 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/-/0JVwyu9PAUQJ. 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.