1const CC = Components.Constructor; 2const BinaryInputStream = CC( 3 "@mozilla.org/binaryinputstream;1", 4 "nsIBinaryInputStream", 5 "setInputStream" 6); 7 8function handleRequest(request, response) { 9 response.setHeader("Content-Type", "text/plain", false); 10 11 var body = new BinaryInputStream(request.bodyInputStream); 12 13 var avail; 14 var bytes = []; 15 while ((avail = body.available()) > 0) { 16 Array.prototype.push.apply(bytes, body.readByteArray(avail)); 17 } 18 19 var data = String.fromCharCode.apply(null, bytes); 20 response.bodyOutputStream.write(data, data.length); 21} 22