michael@0: const CC = Components.Constructor; michael@0: const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1", michael@0: "nsIBinaryInputStream", michael@0: "setInputStream"); michael@0: michael@0: function handleRequest(request, response) michael@0: { michael@0: response.setHeader("Content-Type", "text/plain", false); michael@0: michael@0: var body = new BinaryInputStream(request.bodyInputStream); michael@0: michael@0: var avail; michael@0: var bytes = []; michael@0: while ((avail = body.available()) > 0) michael@0: Array.prototype.push.apply(bytes, body.readByteArray(avail)); michael@0: michael@0: var data = String.fromCharCode.apply(null, bytes); michael@0: response.bodyOutputStream.write(data, data.length); michael@0: }