By HTTP Streaming Comet, I mean the "forever iframe" / "forever xhr" variations that don't close the connection after data has been pushed from the server, as opposed to standard polling and long polling which close and resend a new request for every server push event.
I looked at the dojo.io.cometd package and it seems they only have polling implementations. I also found this example, but it doesn't seem to work in webkit even after a fair bit of tinkering (I got it to work everywhere else). This announcement from the safari blog seems to suggest that it's possible with xhr, but I couldn't find any code or documentation, nor I could get it to work.
Does anyone know of a technique, script, library or demo that accomplishes HTTP streaming comet in Webkit browsers (Safari and Chrome)?
Update
After a bit more tinkering, I found that there are two things that need to be done in order to get http streaming working in Safari via XHR:
- The response needs to have a Content-Type: multipart/x-mixed-replace
- The response needs to send a few "noise" characters before the browser begins to display updates consistently. I'm assuming this has something to do with filling some internal buffer.
Update 2
I finally got it to work in all browsers using an iframe technique. The caveat to the solution is that only WebKit-based browsers should receive the multipart/x-mixed-replace header.