2008-11-05 23:31:30 +00:00
|
|
|
const CC = Components.Constructor;
|
|
|
|
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
|
|
|
|
"nsIBinaryInputStream",
|
|
|
|
"setInputStream");
|
|
|
|
|
2008-08-14 11:07:46 +00:00
|
|
|
function handleRequest(request, response)
|
|
|
|
{
|
|
|
|
response.setHeader("Content-Type", "text/plain", false);
|
2008-09-09 09:32:35 +00:00
|
|
|
if (request.method == "GET") {
|
|
|
|
response.write(request.queryString);
|
|
|
|
} else {
|
2008-11-05 23:31:30 +00: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 09:32:35 +00:00
|
|
|
}
|
2008-08-14 11:07:46 +00:00
|
|
|
}
|
|
|
|
|