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 --- ext/fetch/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ext/fetch/lib.rs') diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index 9fdf80eec..a36512c77 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -745,7 +745,14 @@ pub fn create_http_client( options.client_cert_chain_and_key, )?; - tls_config.alpn_protocols = vec!["h2".into(), "http/1.1".into()]; + let mut alpn_protocols = vec![]; + if options.http2 { + alpn_protocols.push("h2".into()); + } + if options.http1 { + alpn_protocols.push("http/1.1".into()); + } + tls_config.alpn_protocols = alpn_protocols; let mut headers = HeaderMap::new(); headers.insert(USER_AGENT, user_agent.parse().unwrap()); -- cgit v1.2.3