Update main.rs

Add port to host header when not default
This commit is contained in:
Erèbe - Romain Gerard 2023-11-16 12:56:40 +01:00 committed by GitHub
parent 71a937e926
commit 9e0fd6b11a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: (