title: Is Http Streaming Comet possible in Safari?
body: <p>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.</p>
  
  <p>I looked at the dojo.io.cometd package and it seems they only have polling implementations. I also found <a href="http://www.zeitoun.net/articles/comet_and_php/start" rel="noreferrer">this example</a>, but it doesn't seem to work in webkit even after a fair bit of tinkering (I got it to work everywhere else). <a href="http://simonwillison.net/2007/Nov/16/" rel="noreferrer">This announcement from the safari blog</a> 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.</p>
  
  <p>Does anyone know of a technique, script, library or demo that accomplishes HTTP streaming comet in Webkit browsers (Safari and Chrome)? </p>
  
  <p><strong>Update</strong></p>
  
  <p>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:</p>
  
  <ul>
  <li>The response needs to have a Content-Type: multipart/x-mixed-replace</li>
  <li>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.</li>
  </ul>
  
  <p><strong>Update 2</strong></p>
  
  <p>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.</p>