From ec663fad45a0c4b1c311d014f132e4473ec2ce1a Mon Sep 17 00:00:00 2001 From: stelofan Date: Wed, 5 Apr 2023 00:22:53 +0800 Subject: [PATCH] fix cannot use http_proxy connect non-standard http ports --- src/unit.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/unit.rs b/src/unit.rs index 84c41e8..dffc896 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -409,12 +409,21 @@ fn send_prelude(unit: &Unit, stream: &mut Stream) -> io::Result<()> { // HTTP proxies require the path to be in absolute URI form // https://www.rfc-editor.org/rfc/rfc7230#section-5.3.2 match proxy.proto { - Proto::HTTP => format!( - "{}://{}{}", - unit.url.scheme(), - unit.url.host().unwrap(), - unit.url.path() - ), + Proto::HTTP => match unit.url.port() { + Some(port) => format!( + "{}://{}:{}{}", + unit.url.scheme(), + unit.url.host().unwrap(), + port, + unit.url.path() + ), + None => format!( + "{}://{}{}", + unit.url.scheme(), + unit.url.host().unwrap(), + unit.url.path() + ), + }, _ => unit.url.path().into(), } } else {