Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function serve(stat) {
if (onFinished.isFinished(res)) {
return;
}
// Do a MIME lookup, fall back to octet-stream and handle gzip
// and brotli special case.
const defaultType = opts.contentType || 'application/octet-stream';
let contentType = mime.getType(file, defaultType);
let charSet;
const range = (req.headers && req.headers.range);
const lastModified = (new Date(stat.mtime)).toUTCString();
const etag = generateEtag(stat, weakEtags);
let cacheControl = cache;
if (contentType) {
charSet = mime.lookupCharset(contentType);
if (charSet) {
N.wire.after(CHANNELS, { priority: 100 }, function response_send(env) {
var res = env.origin.res,
headers = env.headers,
body = env.body,
statusCode;
// If someone already sent reply - do nothing
if (isFinished(res)) return;
// That should not happen, because custom senders should wait
// stream end.
if (res.headerSent) return;
//
// Set some obligatory headers
//
headers.Server = headers.Server || 'Sansun Calakci';
// added by node automatically
// headers['Date'] = headers['Date'] || new Date).toUTCString();
//
// Remove Accept-Ranges if it wasn't explicitly set
//
N.wire.after(CHANNELS, { priority: 100 }, function response_send(env) {
var res = env.origin.res,
headers = env.headers,
body = env.body,
statusCode;
// If someone already sent reply - do nothing
if (isFinished(res)) return;
// That should not happen, because custom senders should wait
// stream end.
if (res.headerSent) return;
//
// Set some obligatory headers
//
headers.Server = headers.Server || 'Sansun Calakci';
// added by node automatically
// headers['Date'] = headers['Date'] || new Date).toUTCString();
//
// Remove Accept-Ranges if it wasn't explicitly set
//
function serve(stat) {
if (onFinished.isFinished(res)) {
return;
}
// Do a MIME lookup, fall back to octet-stream and handle gzip
// and brotli special case.
const defaultType = opts.contentType || 'application/octet-stream';
let contentType = mime.getType(file, defaultType);
let charSet;
const range = (req.headers && req.headers.range);
const lastModified = (new Date(stat.mtime)).toUTCString();
const etag = generateEtag(stat, weakEtags);
let cacheControl = cache;
if (contentType) {
charSet = mime.lookupCharset(contentType);
if (charSet) {