2008-11-05 15:31:30 -08:00
|
|
|
const CC = Components.Constructor;
|
|
|
|
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
|
|
|
|
"nsIBinaryInputStream",
|
|
|
|
"setInputStream");
|
|
|
|
|
2008-08-14 04:07:46 -07:00
|
|
|
function handleRequest(request, response)
|
|
|
|
{
|
|
|
|
response.setHeader("Content-Type", "text/plain", false);
|
2008-09-09 02:32:35 -07:00
|
|
|
if (request.method == "GET") {
|
|
|
|
response.write(request.queryString);
|
|
|
|
} else {
|
2008-11-05 15:31:30 -08:00
|
|
|
var body = new BinaryInputStream(request.bodyInputStream);
|
|
|
|
|
|
|
|
var avail;
|
|
|
|
var bytes = [];
|
|
|
|
|
|
|
|
while ((avail = body.available()) > 0)
|
|
|
|
Array.prototype.push.apply(bytes, body.readByteArray(avail));
|
|
|
|
|
|
|
|
var data = String.fromCharCode.apply(null, bytes);
|
|
|
|
response.bodyOutputStream.write(data, data.length);
|
2008-09-09 02:32:35 -07:00
|
|
|
}
|
2008-08-14 04:07:46 -07:00
|
|
|
}
|
|
|
|
|