Skip to content

Commit

Permalink
fix(client): get default port for https with Uri
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Mar 21, 2017
1 parent 3d8dddb commit 4f69788
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/client/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 4f69788

Please sign in to comment.