1 const CC = Components.Constructor;
3 const BinaryInputStream = CC(
4 "@mozilla.org/binaryinputstream;1",
5 "nsIBinaryInputStream",
8 const BinaryOutputStream = CC(
9 "@mozilla.org/binaryoutputstream;1",
10 "nsIBinaryOutputStream",
13 const Timer = CC("@mozilla.org/timer;1", "nsITimer", "initWithCallback");
15 function handleRequest(request, response) {
16 var bodyStream = new BinaryInputStream(request.bodyInputStream);
19 while ((bodyAvail = bodyStream.available()) > 0) {
20 Array.prototype.push.apply(bodyBytes, bodyStream.readByteArray(bodyAvail));
23 var bos = new BinaryOutputStream(response.bodyOutputStream);
25 response.processAsync();
27 var part = bodyBytes.splice(0, 256);
28 bos.writeByteArray(part);
30 response.timer1 = new Timer(
32 bos.writeByteArray(bodyBytes);
35 Ci.nsITimer.TYPE_ONE_SHOT
38 response.timer2 = new Timer(
43 Ci.nsITimer.TYPE_ONE_SHOT