tor-browser

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

deliver-gzip.sjs (805B)


      1 "use strict";
      2 
      3 function handleRequest(request, response) {
      4   // The string "hello" repeated 10 times followed by newline. Compressed using gzip.
      5   // prettier-ignore
      6   let bytes = [0x1f, 0x8b, 0x08, 0x08, 0x4d, 0xe2, 0xf9, 0x54, 0x00, 0x03, 0x68,
      7                0x65, 0x6c, 0x6c, 0x6f, 0x00, 0xcb, 0x48, 0xcd, 0xc9, 0xc9, 0xcf,
      8                0x20, 0x85, 0xe0, 0x02, 0x00, 0xf5, 0x4b, 0x38, 0xcf, 0x33, 0x00,
      9                0x00, 0x00];
     10 
     11   response.setHeader("Content-Encoding", "gzip", false);
     12   response.setHeader("Content-Length", "" + bytes.length, false);
     13   response.setHeader("Content-Type", "text/plain", false);
     14 
     15   let bos = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(
     16     Ci.nsIBinaryOutputStream
     17   );
     18   bos.setOutputStream(response.bodyOutputStream);
     19 
     20   bos.writeByteArray(bytes);
     21 }