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:
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
...
On the client side, this is the JavaScript code which I run in Firefox:
var r = new XMLHttpRequest();
r.multipart = true;
r.open('GET', '/', true);
r.onreadystatechange = function () {
console.log(r.responseText.length);
};
r.send();
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?
This is no longer possible, as the support was removed from Firefox. See https://bugzilla.mozilla.org/show_bug.cgi?id=843508