tor-browser

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

bug435425.sjs (677B)


      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", false);
     10   if (request.method == "GET") {
     11     response.write(request.queryString);
     12   } else {
     13     var body = new BinaryInputStream(request.bodyInputStream);
     14 
     15     var avail;
     16     var bytes = [];
     17 
     18     while ((avail = body.available()) > 0) {
     19       Array.prototype.push.apply(bytes, body.readByteArray(avail));
     20     }
     21 
     22     var data = String.fromCharCode.apply(null, bytes);
     23     response.bodyOutputStream.write(data, data.length);
     24   }
     25 }