title: Using multipart/x-mixed-replace with XMLHttpRequest
body: <p>Multipart/x-mixed-replace is a MIME-type for content with multiple parts, each replacing the previous part. This can be used to implement server push / reverse ajax / comet, and apparently should work at least in Firefox. To test this out, I have set up a server which produces the following output with delay between each part:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Content-type: multipart/x-mixed-replace; boundary=whatever
  
  --whatever
  Content-type: text/plain
  
  tick
  
  --whatever
  Content-type: text/plain
  
  tock
  
  --whatever
  ...
  </code></pre>
  
  <p>On the client side, this is the JavaScript code which I run in Firefox:</p>
  
  <pre><code>var r = new XMLHttpRequest();
  r.multipart = true;
  r.open('GET', '/', true);
  r.onreadystatechange = function () {
      console.log(r.responseText.length);
  };
  r.send();
  </code></pre>
  
  <p>I expected each responseText to replace the previous one, but it seems they are actually appended together. The size of the responseText keeps increasing as the server produces more output. Is there a way to only get the latest replaced part?</p>