From 9e0fd6b11a5f861a6c52b7b14809c3ba016709c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Er=C3=A8be=20-=20Romain=20Gerard?= Date: Thu, 16 Nov 2023 12:56:40 +0100 Subject: [PATCH] Update main.rs Add port to host header when not default --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 138a9009..d341b29d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -501,7 +501,11 @@ async fn main() { let host_header = if let Some((_, host_val)) = args.http_headers.iter().find(|(h, _)| *h == HOST) { host_val.clone() } else { - HeaderValue::from_str(&args.remote_addr.host().unwrap().to_string()).unwrap() + let host = match args.remote_addr.port_or_known_default() { + None | Some(80) | Some(443) => args.remote_addr.host().unwrap().to_string(), + Some(port) => format!("{}:{}", args.remote_addr.host().unwrap(), port), + }; + HeaderValue::from_str(&host).unwrap() }; let mut client_config = WsClientConfig { remote_addr: (