summaryrefslogtreecommitdiff
path: root/tests/unit_node/http_test.ts
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2024-07-16 17:46:40 +0530
committerGitHub <noreply@github.com>2024-07-16 14:16:40 +0200
commit6421dc33ede06fb429000c3a560214cdaf573673 (patch)
tree27262bc7a58fe7ac2d0e960cdc2feb4b14584110 /tests/unit_node/http_test.ts
parent04f9db5b2217fe06f88e76146aac6362ff0b0b86 (diff)
fix(ext/node): http request uploads of subarray of buffer should work (#24603)
Closes https://github.com/denoland/deno/issues/24571
Diffstat (limited to 'tests/unit_node/http_test.ts')
-rw-r--r--tests/unit_node/http_test.ts22
1 files changed, 22 insertions, 0 deletions
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<void>();
+ 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");
+});