fix(client): get default port for https with Uri
This commit is contained in:
@@ -71,16 +71,23 @@ impl Service for HttpConnector {
|
|||||||
type Error = io::Error;
|
type Error = io::Error;
|
||||||
type Future = HttpConnecting;
|
type Future = HttpConnecting;
|
||||||
|
|
||||||
fn call(&self, url: Uri) -> Self::Future {
|
fn call(&self, uri: Uri) -> Self::Future {
|
||||||
debug!("Http::connect({:?})", url);
|
debug!("Http::connect({:?})", uri);
|
||||||
let host = match url.host() {
|
let host = match uri.host() {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => return HttpConnecting {
|
None => return HttpConnecting {
|
||||||
state: State::Error(Some(io::Error::new(io::ErrorKind::InvalidInput, "invalid url"))),
|
state: State::Error(Some(io::Error::new(io::ErrorKind::InvalidInput, "invalid url"))),
|
||||||
handle: self.handle.clone(),
|
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 {
|
HttpConnecting {
|
||||||
state: State::Resolving(self.dns.resolve(host.into(), port)),
|
state: State::Resolving(self.dns.resolve(host.into(), port)),
|
||||||
|
|||||||
Reference in New Issue
Block a user