On 1 June 2011 12:55, Geoff G <[email protected]> wrote:
> I am looking to dynamically generate a file and stream it to the client via
> chunked encoding.
> So far, I have:
>         headers = [
>             ('Content-Type', mime_type),
>             ('Content-Disposition',
>              "attachment; filename*=utf-8''%s" % (encoded_filename,)),
>             ]
>         start_response('200 OK', headers)
>         return [chunkone, chunktwo, chunkthree]
> My question is: do I need to add a Transfer-encoding: Chunked header or not?

No.

The key here is not to set Content-Length in response. If the original
request was HTTP/1.1 then with no Content-Length for response, Apache
should then used chunked transfer encoding.

In other words, is actually out of the control of mod_wsgi and
something Apache handles.

If stream you probably want to use yield:

  yield chunkone
  yield chunktwo
  yield chunkthree

or return a generator which in turn does yields.

With the above you are still returning it all in one go, but you most
likely realise that.

Graham

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

Reply via email to