summaryrefslogtreecommitdiffstats
path: root/dom/security/test/mixedcontentblocker/download_server.sjs
blob: e659df2f40b3c7f176234670e623a66a1b51ef9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// force the Browser to Show a Download Prompt

function handleRequest(request, response) {
  let type = "image/png";
  let filename = "hello.png";
  request.queryString.split("&").forEach(val => {
    var [key, value] = val.split("=");
    if (key == "type") {
      type = value;
    }
    if (key == "name") {
      filename = value;
    }
  });

  response.setHeader("Cache-Control", "no-cache", false);
  response.setHeader("Content-Disposition", `attachment; filename=${filename}`);
  response.setHeader("Content-Type", type);
  response.write("🙈🙊🐵🙊");
}