Remove etag from response when modifying headers

This commit is contained in:
Sander Declerck 2025-11-13 16:27:42 +01:00
parent 752504dcc8
commit dc6f37b3ec
No known key found for this signature in database
3 changed files with 18 additions and 8 deletions

View file

@ -188,7 +188,8 @@ function createProxyRequest(hostname, req, res, requestHandler) {
res.end("Internal Server Error");
return;
}
res.writeHead(proxyRes.statusCode, proxyRes.headers);
const { statusCode, headers } = proxyRes;
if (requestHandler.modifiesResponse()) {
/** @type {Array<any>} */
@ -204,17 +205,19 @@ function createProxyRequest(hostname, req, res, requestHandler) {
buffer = gunzipSync(buffer);
}
buffer = requestHandler.modifyBody(buffer);
buffer = requestHandler.modifyBody(buffer, headers);
if (proxyRes.headers["content-encoding"] === "gzip") {
buffer = gzipSync(buffer);
}
res.writeHead(statusCode, headers);
res.end(buffer);
});
} else {
// If the response is not being modified, we can
// just pipe without the need for buffering the output
res.writeHead(statusCode, headers);
proxyRes.pipe(res);
}
});