fix: fix the cache mod not working in Bun, because of extraneous res.writeHead operation
This commit is contained in:
parent
ee8bcb1e60
commit
ed53ea2061
1 changed files with 7 additions and 5 deletions
12
src/index.js
12
src/index.js
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue