From 6c3a5bd9ee6e8fc43a728abcb69d070a3df37f57 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Mon, 13 May 2024 16:59:41 +0200 Subject: [PATCH] Reduced calls to "mime-types" library --- svr.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/svr.js b/svr.js index c49525a..0e63b3b 100644 --- a/svr.js +++ b/svr.js @@ -3684,7 +3684,9 @@ if (!cluster.isPrimary) { if (end > filelen - 1) end = filelen - 1; rhd["Content-Range"] = "bytes " + begin + "-" + end + "/" + filelen; rhd["Content-Length"] = end - begin + 1; - if (!(mime.contentType(ext) == false) && ext != "") rhd["Content-Type"] = mime.contentType(ext); + delete mtype["Content-Type"]; + var mtype = mime.contentType(ext); + if (mtype && ext != "") rhd["Content-Type"] = mtype; if (fileETag) rhd["ETag"] = fileETag; if (req.method != "HEAD") { @@ -3793,7 +3795,8 @@ if (!cluster.isPrimary) { } if (ext != "html") hdhds["Accept-Ranges"] = "bytes"; delete hdhds["Content-Type"]; - if (!(mime.contentType(ext) == false) && ext != "") hdhds["Content-Type"] = mime.contentType(ext); + var mtype = mime.contentType(ext); + if (mtype && ext != "") hdhds["Content-Type"] = mtype; if (fileETag) hdhds["ETag"] = fileETag; if (req.method != "HEAD") {