From a5f57be4df310d51a33faafb307e8c0543e6dc13 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Thu, 2 Jan 2025 22:30:53 +0100 Subject: [PATCH] fix: make res.setHeader, res.removeHeader, res.writeHead, res.end, res.write methods return values --- src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 5510ff2..e31daf0 100644 --- a/src/index.js +++ b/src/index.js @@ -84,12 +84,12 @@ module.exports = function (req, res, logFacilities, config, next) { res.setHeader = function (name, value) { writtenHeaders[name.toLowerCase()] = value; - originalSetHeader(name, value); + return originalSetHeader(name, value); }; res.removeHeader = function (name) { delete writtenHeaders[name.toLowerCase()]; - originalRemoveHeader(name); + return originalRemoveHeader(name); }; res.writeHead = function (statusCode, statusCodeDescription, headers) { @@ -102,13 +102,13 @@ module.exports = function (req, res, logFacilities, config, next) { writtenStatusCode = statusCode; originalSetHeader("X-SVRJS-Cache", "MISS"); if (headers || typeof statusCodeDescription !== "object") { - originalWriteHead( + return originalWriteHead( writtenStatusCode, statusCodeDescription, writtenHeaders ); } else { - originalWriteHead(writtenStatusCode, writtenHeaders); + return originalWriteHead(writtenStatusCode, writtenHeaders); } }; @@ -193,7 +193,7 @@ module.exports = function (req, res, logFacilities, config, next) { } } - originalEnd(chunk, encoding, callback); + return originalEnd(chunk, encoding, callback); }; if (req.method != "HEAD") { @@ -220,7 +220,7 @@ module.exports = function (req, res, logFacilities, config, next) { } } - originalWrite(chunk, encoding, callback); + return originalWrite(chunk, encoding, callback); }; res.on("pipe", (src) => {