From 4f69788f5da54547d39c3a26405f3b4c11fc3f16 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 21 Mar 2017 14:44:04 -0700 Subject: [PATCH] fix(client): get default port for https with Uri --- src/client/connect.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/client/connect.rs b/src/client/connect.rs index 8376287a..fb15e2e8 100644 --- a/src/client/connect.rs +++ b/src/client/connect.rs @@ -71,16 +71,23 @@ impl Service for HttpConnector { type Error = io::Error; type Future = HttpConnecting; - fn call(&self, url: Uri) -> Self::Future { - debug!("Http::connect({:?})", url); - let host = match url.host() { + fn call(&self, uri: Uri) -> Self::Future { + debug!("Http::connect({:?})", uri); + let host = match uri.host() { Some(s) => s, None => return HttpConnecting { state: State::Error(Some(io::Error::new(io::ErrorKind::InvalidInput, "invalid url"))), handle: self.handle.clone(), }, }; - let port = url.port().unwrap_or(80); + let port = match uri.port() { + Some(port) => port, + None => match uri.scheme() { + Some("http") => 80, + Some("https") => 443, + _ => 80, + }, + }; HttpConnecting { state: State::Resolving(self.dns.resolve(host.into(), port)),