tor-browser

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

blob_verify.sjs (707B)


      1 const CC = Components.Constructor;
      2 const BinaryInputStream = CC(
      3   "@mozilla.org/binaryinputstream;1",
      4   "nsIBinaryInputStream",
      5   "setInputStream"
      6 );
      7 const BinaryOutputStream = CC(
      8   "@mozilla.org/binaryoutputstream;1",
      9   "nsIBinaryOutputStream",
     10   "setOutputStream"
     11 );
     12 
     13 function handleRequest(request, response) {
     14   var bodyStream = new BinaryInputStream(request.bodyInputStream);
     15   var bodyBytes = [];
     16   let bodyAvail;
     17   while ((bodyAvail = bodyStream.available()) > 0) {
     18     Array.prototype.push.apply(bodyBytes, bodyStream.readByteArray(bodyAvail));
     19   }
     20 
     21   var bos = new BinaryOutputStream(response.bodyOutputStream);
     22 
     23   response.processAsync();
     24   bos.writeByteArray(bodyBytes);
     25   response.finish();
     26 }