fix: fix the cache mod not working in Bun, because of extraneous res.writeHead operation

This commit is contained in:
Dorian Niemiec 2024-12-19 22:33:01 +01:00
parent ee8bcb1e60
commit ed53ea2061

View file

@ -77,11 +77,13 @@ module.exports = function (req, res, logFacilities, config, next) {
res.writeHead = function (statusCode, statusCodeDescription, headers) {
const properHeaders = headers ? headers : statusCodeDescription;
Object.keys(properHeaders).forEach((key) => {
writtenHeaders[key.toLowerCase()] = properHeaders[key];
});
writtenStatusCode = statusCode;
res.setHeader("X-SVRJS-Cache", "MISS");
if (typeof properHeaders === "object" && properHeaders !== null) {
Object.keys(properHeaders).forEach((key) => {
writtenHeaders[key.toLowerCase()] = properHeaders[key];
});
writtenStatusCode = statusCode;
res.setHeader("X-SVRJS-Cache", "MISS");
}
if (headers) {
originalWriteHead(
writtenStatusCode,