download_server.sjs (475B)
1 function handleRequest(request, response) { 2 // Only answer to http, in case request is in https let the reply time out. 3 if (request.scheme === "https") { 4 response.processAsync(); 5 return; 6 } 7 8 response.setHeader("Cache-Control", "no-cache", false); 9 // Send some file, e.g. an image 10 response.setHeader( 11 "Content-Disposition", 12 "attachment; filename=some-file.png" 13 ); 14 response.setHeader("Content-Type", "image/png"); 15 response.write("Success!"); 16 }