diff options
author | Andreu Botella <abb@randomunok.com> | 2021-10-25 09:41:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 18:41:06 +0200 |
commit | e39dace8cb4b1868e811fd13b87f2a81e84b98ce (patch) | |
tree | 3ed900bdd0e340ae74c9278846d407092bfa1901 /cli/tests/unit/fetch_test.ts | |
parent | 2e888cc82433aa143c0edadbd8c134b8fe030f50 (diff) |
fix(tls): Make TLS clients support HTTP/2 (#12530)
`fetch()` and client-side websocket used to support HTTP/2, but this
regressed in #11491. This patch reenables it by explicitly adding `h2`
and `http/1.1` to the list of ALPN protocols on the HTTP and websocket
clients.
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index a2bd1741b..bc61d67b5 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -1324,3 +1324,39 @@ unitTest( }), TypeError); }, ); + +unitTest( + { permissions: { net: true, read: true } }, + async function fetchSupportsHttp1Only() { + const caCert = await Deno.readTextFile("cli/tests/testdata/tls/RootCA.pem"); + const client = Deno.createHttpClient({ caCerts: [caCert] }); + const res = await fetch("https://localhost:5546/http_version", { client }); + assert(res.ok); + assertEquals(await res.text(), "HTTP/1.1"); + client.close(); + }, +); + +unitTest( + { permissions: { net: true, read: true } }, + async function fetchSupportsHttp2() { + const caCert = await Deno.readTextFile("cli/tests/testdata/tls/RootCA.pem"); + const client = Deno.createHttpClient({ caCerts: [caCert] }); + const res = await fetch("https://localhost:5547/http_version", { client }); + assert(res.ok); + assertEquals(await res.text(), "HTTP/2.0"); + client.close(); + }, +); + +unitTest( + { permissions: { net: true, read: true } }, + async function fetchPrefersHttp2() { + const caCert = await Deno.readTextFile("cli/tests/testdata/tls/RootCA.pem"); + const client = Deno.createHttpClient({ caCerts: [caCert] }); + const res = await fetch("https://localhost:5545/http_version", { client }); + assert(res.ok); + assertEquals(await res.text(), "HTTP/2.0"); + client.close(); + }, +); |