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