From 856480cd902923049cca066509d44486c6a391db Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Sun, 29 Dec 2024 17:55:32 +0100 Subject: [PATCH] fix(http2): remove host header when using http2 (#3516) Co-authored-by: Rob Ede --- awc/CHANGES.md | 1 + awc/src/client/h2proto.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 8a2a1ec43..df3003981 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -5,6 +5,7 @@ - Update `brotli` dependency to `7`. - Prevent panics on connection pool drop when Tokio runtime is shutdown early. - Minimum supported Rust version (MSRV) is now 1.75. +- Do not send `Host` header on HTTP/2 requests, as it is not required, and some web servers may reject it. ## 3.5.1 diff --git a/awc/src/client/h2proto.rs b/awc/src/client/h2proto.rs index c3f801f20..f12ac3b43 100644 --- a/awc/src/client/h2proto.rs +++ b/awc/src/client/h2proto.rs @@ -12,7 +12,7 @@ use h2::{ SendStream, }; use http::{ - header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING}, + header::{HeaderValue, CONNECTION, CONTENT_LENGTH, HOST, TRANSFER_ENCODING}, request::Request, Method, Version, }; @@ -97,7 +97,7 @@ where // TODO: consider skipping other headers according to: // https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.2 // omit HTTP/1.x only headers - CONNECTION | TRANSFER_ENCODING => continue, + CONNECTION | TRANSFER_ENCODING | HOST => continue, CONTENT_LENGTH if skip_len => continue, // DATE => has_date = true, _ => {}