tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

echo.sjs (624B)


      1 const CC = Components.Constructor;
      2 const BinaryInputStream = CC(
      3   "@mozilla.org/binaryinputstream;1",
      4   "nsIBinaryInputStream",
      5   "setInputStream"
      6 );
      7 
      8 function handleRequest(request, response) {
      9   response.setHeader("Content-Type", "text/plain");
     10   if (request.method == "GET") {
     11     response.write(request.queryString);
     12     return;
     13   }
     14 
     15   var bodyStream = new BinaryInputStream(request.bodyInputStream);
     16   var body = "";
     17   var bodyAvail;
     18   while ((bodyAvail = bodyStream.available()) > 0) {
     19     body += String.fromCharCode.apply(
     20       null,
     21       bodyStream.readByteArray(bodyAvail)
     22     );
     23   }
     24 
     25   response.write(body);
     26 }