Every line of 'express res.sendfile' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
86 function sendFile(filePath: string, response: http.ServerResponse, 87 alternatePath: string = "", isDynamic: boolean = false) { 88 var extension = path.extname(filePath); 89 var contentType = CONTENT_TYPES[extension.toLowerCase()] || 'application/octet-stream'; 90 91 getContent(filePath, function(error, content) { 92 if (error) { 93 logging.getLogger().error(error, 'Unable to send static file: %s', filePath); 94 95 if (alternatePath != "") { 96 sendDataLabFile(alternatePath, response); 97 } else { 98 response.writeHead(500); 99 response.end(); 100 } 101 } 102 else { 103 if (isDynamic) { 104 response.removeHeader('Cache-Control'); 105 response.setHeader('Cache-Control', 'no-cache'); 106 } 107 response.writeHead(200, { 'Content-Type': contentType }); 108 response.end(content); 109 } 110 }, isDynamic); 111 }