On Jul 1, 7:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> It's quite a large restriction to say that no middleware should ever try
> to examine the contents of the HttpResponse since it might be an
> iterator that shouldn't be consumed. You're proposing a bunch of
> specific changes for the middleware we have now to work around that, but
> you're also imposing a huge functionality constraint on any future
> middleware (all middleware will have to work with the possibility that a
> non-consumable generator is there).

I don't think that restriction true, and even if it were it wouldn't
be a significant change from the present functionality, or your
suggested functionality of consuming generators immediately.

If someone passes a "non-consumable" generator as content (either to
be consumed immediately or by 3rd party middleware), or simply had
potentially long running code in their views, the end result is the
same. A timeout in the browser. Supporting streaming HttpResponse
objects at least gives developers a *chance* to avoid these timeouts.

3rd party middleware can continue to access HttpResponse.content
directly and consume generators if they like. There doesn't have to be
a requirement that ALL middleware fully support streaming
HttpResponse. Clearly some middleware which need to manipulate or
access the entire content as a string cannot be streamed. But the core
Django middleware shouldn't consume content generators unnecessarily
and 3rd party middleware developers should have the *option* of
allowing content generators to go unmolested.

All that's required is a public attribute on HttpResponse that
middleware developers can access if they want to be aware of content
generators, to fix code Django middleware to be aware of this where
possible and where appropriate, and leave the default as it is - for
HttpResponse.content to consume content generators.


--~--~---------~--~----~------------~-------~--~----~
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