>I need to be able to serve potentially large log files with Django. (I >can't serve them as static files.) Rather than loading them into memory >and giving their contents to an HttpResponse object as a string, is it >possible to stream them back to the browser? I'm imagining something like >this:
With WSGI directly you can have a request be a generator instead of a string. In that case the parts the generator yields will be sent out part-by-part. And WSGI frameworks will use chunked transport - that way you won't need to read the whole beast into memory and the browser will get parts as they are available and so won't stall if it takes longer to produce parts. Currently Django doesn't use this feature - but I think it might be cool if one would be able to pass a generator to HTTPResponse instead of a string and if Django would make use of the WSGI generator feature to send out chunked parts. But to do this there would have to be support for chunked transfers in the mod_python handler, too, so it wouldn't be a simple patch, but a bit more involved. bye, Georg