aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-11 13:09:37 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-11 13:09:37 -0700
commitfd4c8fb871c12157f64b4d6297614dcc8f571ddd (patch)
tree907cfe1a8e5cf86d38e1395f462a0785a72c002a /test
parent5c8726d602fe73e49d027194fef65b9432872c8b (diff)
parentbab58b754156cdd749faa6e5ee41bd4758346da6 (diff)
downloadbun-fd4c8fb871c12157f64b4d6297614dcc8f571ddd.tar.gz
bun-fd4c8fb871c12157f64b4d6297614dcc8f571ddd.tar.zst
bun-fd4c8fb871c12157f64b4d6297614dcc8f571ddd.zip
Merge branch 'jarred/fix-http-compression'
Diffstat (limited to 'test')
-rw-r--r--test/js/node/http/node-http.test.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts
index 3e7da9d34..0e7b3ca13 100644
--- a/test/js/node/http/node-http.test.ts
+++ b/test/js/node/http/node-http.test.ts
@@ -146,6 +146,29 @@ describe("node:http", () => {
res.end("Path correct!\n");
return;
}
+ if (reqUrl.pathname === "/customWriteHead") {
+ function createWriteHead(prevWriteHead, listener) {
+ let fired = false;
+ return function writeHead() {
+ if (!fired) {
+ fired = true;
+ listener.call(this);
+ }
+ return prevWriteHead.apply(this, arguments);
+ };
+ }
+
+ function addPoweredBy() {
+ if (!this.getHeader("X-Powered-By")) {
+ this.setHeader("X-Powered-By", "Bun");
+ }
+ }
+
+ res.writeHead = createWriteHead(res.writeHead, addPoweredBy);
+ res.setHeader("Content-Type", "text/plain");
+ res.end("Hello World");
+ return;
+ }
}
res.writeHead(200, { "Content-Type": "text/plain" });
@@ -507,6 +530,16 @@ describe("node:http", () => {
req.end();
});
});
+ it("reassign writeHead method, issue#3585", done => {
+ runTest(done, (server, serverPort, done) => {
+ const req = request(`http://localhost:${serverPort}/customWriteHead`, res => {
+ expect(res.headers["content-type"]).toBe("text/plain");
+ expect(res.headers["x-powered-by"]).toBe("Bun");
+ done();
+ });
+ req.end();
+ });
+ });
});
describe("signal", () => {