[Zope-dev] Streaming Response

Danny W. Adair danny@adair.net
Tue, 08 Apr 2003 13:19:55 +1200


At 05:58 PM 4/7/2003 -0700, Brett Carter wrote:
><snip>
>
> > I would like to use Response.write() to push my status messages on the fly.
> > Since I don't know which function calls will succeed and which will 
> fail, I
> > do not know "Content-Length" in advance. Therefore, I would like to use a
> > streaming/chunked response as specified in HTTP 1.1.
>
>I just finished a library to do just this.  I'll have to ask my employer if
>I can release it, but I'm not sure http chunking is exactly what you want.
>Chunking takes the current page and dynamically replaces it with whatever
>new content you send in each chunk.

That would be really cool. I guess replacing will be fine: If I need to 
quote stuff from the "old" page, I'll just include it again...


> > How do I do this in Zope?
> >
> > I tried to do "response.setHeader('Content-Type',
> > 'multipart/x-mixed-replace')" but couldn't get it working. (Also, it looks
> > as if this will only work in Netscape but not IE. True? Then unfortunately
> > I can't go that route anyway.)
>
>You're on the right track, I just used a combonation of response.setHeader
>and response.write.  You're also correct that IE doesn't support chunking;
>better send a bug report to bill.  That said, I'm not sure this method ever
>even made it into the HTTP spec, but all netscape and gecko based browsers
>support it in my experience.  I've seen other sites make IE work with an
>ActiveX plugin of some sort; don't ask me where or how to get it, I don't
>do IE.

Mmmhhh. When playing around with "content-type" and "transfer-encoding" I 
actually got something back from IE6 that looked like it was doing the 
right thing. But then again there were "etag" and "transfer-ecnoding" 
quoted on the page, which I never (directly) invoked. Also some numbers. 
Very odd.

I think I need a bit more insight on HTTPResponse.py and how it deals with 
manipulations, but I find it hard to read its source code. Also, what's the 
exact difference between streaming and chunking? (I've got an idea but no 
facts, esp. in regards to HTTPResponse.py)


> > I also tried to leave the header alone and just "Response.write()" the
> > multipart content-type and its boundary and the content-type's of the
> > parts, but ZPublisher just returned the plain text...
>
>Getting the headers set correctly is a bit tricky, each chunk needs to be
>delimited by a set of boundry strings defined when you first set your
>content type header.  The full explaination is at:
>http://wp.netscape.com/assist/net_sites/pushpull.html

Yup, read that. And I enjoyed reading "mimetools.choose_boundary()", too. lol

My problem now is that I need something that works with IE. There's funny 
things going on with my hairs and toes when I hear the word "ActiveX 
plugin", so I'm still hoping for alternatives.

Thank you for your response :-), and that library of yours sounds like a 
good thing(tm). Maybe you can ask your employer if you can pass it on.

Cheers,
Danny



>-Brett