[Zope3-dev] RFC: Make HTTP streaming of large data simpler

Sidnei da Silva sidnei at enfoldsystems.com
Mon Dec 5 13:31:03 EST 2005


On Mon, Dec 05, 2005 at 01:24:54PM -0500, Paul Winkler wrote:
| On Mon, Dec 05, 2005 at 11:13:31AM -0500, Jim Fulton wrote:
| > BTW, your implementation also doesn't work because it doesn't
| > set the content length.
| 
| Speaking of which, I'd love to see a way to make this work for
| situations where you can't precompute a correct content length because
| e.g. you're building a lot of data on the fly but you still want to
| start streaming it as early as possible.
| In this case, the HTTP spec says that you should NOT set the
| content-length header but you must close the channel to signal "end of
| data".  Or at least that's what Dieter says it says :-)
| http://mail.zope.org/pipermail/zope/2005-November/162714.html
| 
| Apparently, according to Dieter, Zope 2 doesn't let you use this idiom;
| does zope 3?  (I've very briefly looked at the Zope 2 code in medusa,
| and I can't quite tell if Dieter is correct - there seems to be some
| support for the "chunked" transfer coding, which should do the job, but
| I'm not sure if/how one can currently take advantage of it.)

There are a couple conditions that must be met for 'chunked' to work
with Zope 2.

1. A Content-Length header must not be set.
2. The request must be HTTP 1.1
3. You must be streaming
4. No 'Connection: close' header has been set during the request

If all of that is met, then it works just fine. The signal for 'end of
data' in chunked mode is '0\r\n\r\n', which Zope properly inserts when
appropriate.

-- 
Sidnei da Silva
Enfold Systems, LLC.
http://enfoldsystems.com


More information about the Zope3-dev mailing list