From 2b6f8d01877a1bceb0910396425f1ee04c8b0fa2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 26 Sep 2021 20:26:16 +0200 Subject: fix(ext/http): include port number in h2 urls (#12181) --- ext/http/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/http/lib.rs b/ext/http/lib.rs index aabf5d839..f1b0c911a 100644 --- a/ext/http/lib.rs +++ b/ext/http/lib.rs @@ -280,7 +280,13 @@ fn req_url( scheme: &'static str, addr: SocketAddr, ) -> Result { - let host: Cow = if let Some(host) = req.uri().host() { + let host: Cow = if let Some(auth) = req.uri().authority() { + match addr.port() { + 443 if scheme == "https" => Cow::Borrowed(auth.host()), + 80 if scheme == "http" => Cow::Borrowed(auth.host()), + _ => Cow::Borrowed(auth.as_str()), // Includes port number. + } + } else if let Some(host) = req.uri().host() { Cow::Borrowed(host) } else if let Some(host) = req.headers().get("HOST") { Cow::Borrowed(host.to_str()?) -- cgit v1.2.3