file_nohttps_download.sjs (740B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 function handleRequest(request, response) { 7 if (request.scheme === "https") { 8 // this file is only available over http! 9 response.setHeader("Cache-Control", "no-cache", false); 10 response.setStatusLine("1.1", 404, "Not Found"); 11 response.write("This is the HTTPS response... - No such file here!"); 12 } else { 13 response.processAsync(); 14 response.setHeader("Cache-Control", "no-cache", false); 15 response.setHeader("Content-Disposition", "attachment; filename=file.txt"); 16 response.setHeader("Content-Type", "text/plain"); 17 response.write("File contents!\n"); 18 response.finish(); 19 } 20 }