summaryrefslogtreecommitdiff
path: root/tests/unit_node/http2_test.ts
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2024-07-29 17:03:55 +0530
committerGitHub <noreply@github.com>2024-07-29 13:33:55 +0200
commit8bab761bccf976ac568b0b3f4decfd7e77747767 (patch)
tree798debeb571b1d557506a9ba69fd927a162e5f84 /tests/unit_node/http2_test.ts
parentad5cec27d3ba67c67e501f612d361254def78194 (diff)
fix(ext/node): prevent panic in http2.connect with uppercase header names (#24780)
Closes https://github.com/denoland/deno/issues/24678
Diffstat (limited to 'tests/unit_node/http2_test.ts')
-rw-r--r--tests/unit_node/http2_test.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit_node/http2_test.ts b/tests/unit_node/http2_test.ts
index 67c2497d5..edaac8234 100644
--- a/tests/unit_node/http2_test.ts
+++ b/tests/unit_node/http2_test.ts
@@ -243,3 +243,35 @@ Deno.test("[node/http2 client] write 512kb buffer on request stream works", asyn
await endPromise.promise;
assertEquals(receivedData!, buffer);
});
+
+// https://github.com/denoland/deno/issues/24678
+Deno.test("[node/http2 client] deno doesn't panic on uppercase headers", async () => {
+ const url = "http://127.0.0.1:4246";
+ const client = http2.connect(url);
+ client.on("error", (err) => console.error(err));
+
+ // The "User-Agent" header has uppercase characters to test the panic.
+ const req = client.request({
+ ":method": "POST",
+ ":path": "/",
+ "User-Agent": "http2",
+ });
+ const endPromise = Promise.withResolvers<void>();
+
+ let receivedData = "";
+
+ req.write("hello");
+ req.setEncoding("utf8");
+
+ req.on("data", (chunk) => {
+ receivedData += chunk;
+ });
+ req.on("end", () => {
+ req.close();
+ client.close();
+ endPromise.resolve();
+ });
+ req.end();
+ await endPromise.promise;
+ assertEquals(receivedData, "hello world\n");
+});