From d90a75c0361e2d2bf45d6605cb0c7cb6d1a335a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 29 May 2023 23:05:45 +0200 Subject: fix: use proper ALPN protocols if HTTP client is HTTP/1.1 only (#19303) Closes https://github.com/denoland/deno/issues/16923 --------- Co-authored-by: crowlkats Co-authored-by: Matt Mastracci --- cli/tests/unit_node/http_test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cli/tests/unit_node') diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts index 5eb8c15bd..d1ed11632 100644 --- a/cli/tests/unit_node/http_test.ts +++ b/cli/tests/unit_node/http_test.ts @@ -2,6 +2,7 @@ import EventEmitter from "node:events"; import http, { type RequestOptions } from "node:http"; +import https from "node:https"; import { assert, assertEquals, @@ -509,3 +510,24 @@ Deno.test("[node/http] ClientRequest handle non-string headers", async () => { await def; assertEquals(headers!["1"], "2"); }); + +Deno.test("[node/http] ClientRequest uses HTTP/1.1", async () => { + let body = ""; + const def = deferred(); + const req = https.request("https://localhost:5545/http_version", { + method: "POST", + headers: { 1: 2 }, + }, (resp) => { + resp.on("data", (chunk) => { + body += chunk; + }); + + resp.on("end", () => { + def.resolve(); + }); + }); + req.once("error", (e) => def.reject(e)); + req.end(); + await def; + assertEquals(body, "HTTP/1.1"); +}); -- cgit v1.2.3