diff options
author | Satya Rohith <me@satyarohith.com> | 2024-02-21 18:13:01 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-21 18:13:01 +0530 |
commit | 061ee9d38cdf8ff0ade2373c1e075f841c534c47 (patch) | |
tree | aac131b573bf051ef714c8c7f1a6bbc2c51de824 /tests | |
parent | c75c9a072715d6c0f3a91725b75ff62708c5e011 (diff) |
fix(ext/node): pass alpnProtocols to Deno.startTls (#22512)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit_node/http2_test.ts | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/unit_node/http2_test.ts b/tests/unit_node/http2_test.ts index 2ea292485..fd9cdd0ec 100644 --- a/tests/unit_node/http2_test.ts +++ b/tests/unit_node/http2_test.ts @@ -2,7 +2,7 @@ import * as http2 from "node:http2"; import * as net from "node:net"; -import { assertEquals } from "@std/assert/mod.ts"; +import { assert, assertEquals } from "@std/assert/mod.ts"; for (const url of ["http://127.0.0.1:4246", "https://127.0.0.1:4247"]) { Deno.test(`[node/http2 client] ${url}`, { @@ -136,3 +136,32 @@ Deno.test("[node/http2 server]", { sanitizeOps: false }, async () => { await new Promise((resolve) => server.close(resolve)); }); + +Deno.test("[node/http2 client GET https://www.example.com]", async () => { + const clientSession = http2.connect("https://www.example.com"); + const req = clientSession.request({ + ":method": "GET", + ":path": "/", + }); + let headers = {}; + let status: number | undefined = 0; + let chunk = new Uint8Array(); + const endPromise = Promise.withResolvers<void>(); + req.on("response", (h) => { + status = h[":status"]; + headers = h; + }); + req.on("data", (c) => { + chunk = c; + }); + req.on("end", () => { + clientSession.close(); + req.close(); + endPromise.resolve(); + }); + req.end(); + await endPromise.promise; + assert(Object.keys(headers).length > 0); + assertEquals(status, 200); + assert(chunk.length > 0); +}); |