diff options
author | 2023-03-01 23:28:21 -0600 | |
---|---|---|
committer | 2023-03-01 21:28:21 -0800 | |
commit | b9137dbdc81591f8b30cf95a4d27514bfb1ae71c (patch) | |
tree | c369d655111fbc3d1d346dbfc22f3d2f699a33e9 /test/bun.js/node-http.test.ts | |
parent | 706a3e8169ae27b1b5c3694d46b593f220c41b80 (diff) | |
download | bun-b9137dbdc81591f8b30cf95a4d27514bfb1ae71c.tar.gz bun-b9137dbdc81591f8b30cf95a4d27514bfb1ae71c.tar.zst bun-b9137dbdc81591f8b30cf95a4d27514bfb1ae71c.zip |
fix(node:http): match Node `http.request()` GET/HEAD w/ body (#2262)
Diffstat (limited to 'test/bun.js/node-http.test.ts')
-rw-r--r-- | test/bun.js/node-http.test.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/bun.js/node-http.test.ts b/test/bun.js/node-http.test.ts index 40102cd9a..7818fba62 100644 --- a/test/bun.js/node-http.test.ts +++ b/test/bun.js/node-http.test.ts @@ -386,6 +386,31 @@ describe("node:http", () => { req.write("Hello World"); req.end(); }); + + it("should ignore body when method is GET/HEAD/OPTIONS", done => { + const createDone = createDoneDotAll(done); + const methods = ["GET", "HEAD", "OPTIONS"]; + const dones = {}; + for (const method of methods) { + dones[method] = createDone(); + } + for (const method of methods) { + const req = request(`http://localhost:${serverPort}`, { method }, res => { + let data = ""; + res.setEncoding("utf8"); + res.on("data", chunk => { + data += chunk; + }); + res.on("end", () => { + expect(data).toBe(method === "GET" ? "Maybe GET maybe not\nHello World" : ""); + dones[method](); + }); + res.on("error", err => dones[method](err)); + }); + req.write("BODY"); + req.end(); + } + }); }); describe("signal", () => { |