Skip to content

Commit 4f69788

Browse files
committed
fix(client): get default port for https with Uri
1 parent 3d8dddb commit 4f69788

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/client/connect.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,23 @@ impl Service for HttpConnector {
7171
type Error = io::Error;
7272
type Future = HttpConnecting;
7373

74-
fn call(&self, url: Uri) -> Self::Future {
75-
debug!("Http::connect({:?})", url);
76-
let host = match url.host() {
74+
fn call(&self, uri: Uri) -> Self::Future {
75+
debug!("Http::connect({:?})", uri);
76+
let host = match uri.host() {
7777
Some(s) => s,
7878
None => return HttpConnecting {
7979
state: State::Error(Some(io::Error::new(io::ErrorKind::InvalidInput, "invalid url"))),
8080
handle: self.handle.clone(),
8181
},
8282
};
83-
let port = url.port().unwrap_or(80);
83+
let port = match uri.port() {
84+
Some(port) => port,
85+
None => match uri.scheme() {
86+
Some("http") => 80,
87+
Some("https") => 443,
88+
_ => 80,
89+
},
90+
};
8491

8592
HttpConnecting {
8693
state: State::Resolving(self.dns.resolve(host.into(), port)),

0 commit comments

Comments
 (0)