aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/node-http.test.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/bun.js/node-http.test.ts25
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", () => {