tor-browser

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

download_with_content_disposition_header.sjs (696B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 function handleRequest(request, response) {
      6   let page = "download";
      7   response.setStatusLine(request.httpVersion, "200", "OK");
      8 
      9   let [first, second] = request.queryString.split("=");
     10   let headerStr = first;
     11   if (second !== "none") {
     12     headerStr += "; filename=" + second;
     13   }
     14 
     15   response.setHeader("Content-Disposition", headerStr);
     16   response.setHeader("Content-Type", "text/plain", false);
     17   response.setHeader("Content-Length", page.length + "", false);
     18   response.write(page);
     19 }