From 6421dc33ede06fb429000c3a560214cdaf573673 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Tue, 16 Jul 2024 17:46:40 +0530 Subject: fix(ext/node): http request uploads of subarray of buffer should work (#24603) Closes https://github.com/denoland/deno/issues/24571 --- tests/unit_node/http_test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/unit_node') diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts index 9a37722c7..b9fe767e6 100644 --- a/tests/unit_node/http_test.ts +++ b/tests/unit_node/http_test.ts @@ -1406,3 +1406,25 @@ Deno.test("[node/http] Server.address() can be null", () => { const server = http.createServer((_req, res) => res.end("it works")); assertEquals(server.address(), null); }); + +Deno.test("[node/http] ClientRequest PUT subarray", async () => { + const buffer = Buffer.from("hello world"); + const payload = buffer.subarray(6, 11); + let body = ""; + const { promise, resolve, reject } = Promise.withResolvers(); + const req = http.request("http://localhost:4545/echo_server", { + method: "PUT", + }, (resp) => { + resp.on("data", (chunk) => { + body += chunk; + }); + + resp.on("end", () => { + resolve(); + }); + }); + req.once("error", (e) => reject(e)); + req.end(payload); + await promise; + assertEquals(body, "world"); +}); -- cgit v1.2.3