From 3fc7b30ccd54be415ee6047fa6d51ee482986e3b Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Wed, 18 Dec 2024 19:11:01 +0100 Subject: [PATCH] fix: fix header name casing inconsistencies causing wrong caching behavior --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 3437b72..f60a812 100644 --- a/src/index.js +++ b/src/index.js @@ -76,10 +76,10 @@ module.exports = function (req, res, logFacilities, config, next) { let maximumCachedResponseSizeExceeded = false; res.writeHead = function (statusCode, statusCodeDescription, headers) { - writtenHeaders = Object.assign( - writtenHeaders, - headers ? headers : statusCodeDescription - ); + const properHeaders = headers ? headers : statusCodeDescription; + Object.keys(properHeaders).forEach((key) => { + writtenHeaders[key.toLowerCase()] = properHeaders[key]; + }); writtenStatusCode = statusCode; res.setHeader("X-SVRJS-Cache", "MISS"); if (headers) {