>> - A hypothetical middleware that appends debug information to the end
>>   of the response. debug-toolbar may be able to work like this.
> Looking for the </body> boils down to the same problem as above, and can't be 
> implemented without consuming the content for the same reason.

It can be done, it's just a little harder for streaming. If the chunk
you are processing ends with any prefix of '</body>', that is, ('<',
'</', '</b', '</bo', ...), you combine it with the next chunk and look
for '</body>' again.. I don't think this counts as 'consuming' the
content, because you'll only combine combine a few chunks, and only
when necessary.

This treatment, while difficult, is totally necessary when dealing
with iterators over responses, no matter the API. Since you have to
write the complex stream processing anyway (assuming you want to work
with streaming responses), HttpResponse should not force you to write
an additional implementation for the plain, non-streaming response.

> You can probably abstract the pattern in a response middleware base class.
That's a good idea, and it's probably what I'll do if this doesn't
make it into Django. I think this use case is common enough for
HttpResponse to handle, though.

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