1 const CC = Components.Constructor;
3 const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
4 "nsIBinaryInputStream",
6 const BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1",
7 "nsIBinaryOutputStream",
9 const Timer = CC("@mozilla.org/timer;1",
13 function handleRequest(request, response) {
14 var bodyStream = new BinaryInputStream(request.bodyInputStream);
16 while ((bodyAvail = bodyStream.available()) > 0)
17 Array.prototype.push.apply(bodyBytes, bodyStream.readByteArray(bodyAvail));
19 var bos = new BinaryOutputStream(response.bodyOutputStream);
21 response.processAsync();
23 var part = bodyBytes.splice(0, 256);
24 bos.writeByteArray(part);
26 response.timer1 = new Timer(function(timer) {
27 bos.writeByteArray(bodyBytes);
28 }, 1000, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
30 response.timer2 = new Timer(function(timer) {
32 }, 2000, Components.interfaces.nsITimer.TYPE_ONE_SHOT);