On Sep 23, 3:54 am, mrts <[EMAIL PROTECTED]> wrote:
> +1 for adding a way to say "process_response should never be called on
> this response".
>
> Taking a quick look at the source, HttpResponse seems to support
> iteration already:
>
>     def __iter__(self):
>         self._iterator = iter(self._container)
>         return self
>
>     def next(self):
>         chunk = self._iterator.next()
>         if isinstance(chunk, unicode):
>             chunk = chunk.encode(self._charset)
>         return str(chunk)
>
> I'd expect this is actually used in returning content, i.e. if no
> middleware kicks in, passing an iterator to HttpResponse should just
> work for streaming?

I believe that's correct. However, I'm still not so sure about
stopping `process_response` from running for *all* middleware. As
mentioned above, some middleware can work and are useful with a
streaming response. How about these two ideas:

1) Add a `skipped_middleware` attribute to HttpResponse which is empty
by default, and when looping through and executing middleware, skip
those defined in there. That way the developer can either subclass
`HttpResponse` or simply modify an `HttpResponse` instance before
returning and specify exactly which middleware should be skipped?

2) Create an `HttpStreamingResponse` class and add a `can_stream`
attribute to each middleware which defaults to `False`. When you need
streaming functionality use the provided `HttpStreamingResponse` class
which will automatically skip any middleware for which `can_stream` is
`False`.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to