diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-05-29 23:05:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-29 23:05:45 +0200 |
commit | d90a75c0361e2d2bf45d6605cb0c7cb6d1a335a7 (patch) | |
tree | 107f9f3be7a17511b53b99a36084ab172c3a04b8 /ext/fetch/lib.rs | |
parent | fc6ba92024d76d44349c36dcedd13994116db45b (diff) |
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 <crowlkats@toaxl.com>
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
Diffstat (limited to 'ext/fetch/lib.rs')
-rw-r--r-- | ext/fetch/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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()); |