fix cannot use http_proxy connect non-standard http ports

This commit is contained in:
stelofan
2023-04-05 00:22:53 +08:00
committed by Martin Algesten
parent 2e7bcf255a
commit ec663fad45

View File

@@ -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 // HTTP proxies require the path to be in absolute URI form
// https://www.rfc-editor.org/rfc/rfc7230#section-5.3.2 // https://www.rfc-editor.org/rfc/rfc7230#section-5.3.2
match proxy.proto { match proxy.proto {
Proto::HTTP => format!( 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.scheme(),
unit.url.host().unwrap(), unit.url.host().unwrap(),
unit.url.path() unit.url.path()
), ),
},
_ => unit.url.path().into(), _ => unit.url.path().into(),
} }
} else { } else {