Skip to content

Commit

Permalink
refactor(client): update from deprecated Uri::port to port_part (#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLabonte authored and seanmonstar committed Nov 26, 2018
1 parent 7fb6e3a commit 69368f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/client/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ where
Some(s) => s,
None => return invalid_url(InvalidUrl::MissingAuthority, &self.handle),
};
let port = match dst.uri.port() {
Some(port) => port,
let port = match dst.uri.port_part() {
Some(port) => port.as_u16(),
None => if dst.uri.scheme_part() == Some(&Scheme::HTTPS) { 443 } else { 80 },
};

Expand Down
7 changes: 5 additions & 2 deletions src/client/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ impl Destination {
/// Get the port, if specified.
#[inline]
pub fn port(&self) -> Option<u16> {
self.uri.port()
match self.uri.port_part() {
Some(port) => Some(port.as_u16()),
None => None
}
}

/// Update the scheme of this destination.
Expand Down Expand Up @@ -140,7 +143,7 @@ impl Destination {
.map_err(::error::Parse::from)?
} else {
let auth = host.parse::<uri::Authority>().map_err(::error::Parse::from)?;
if auth.port().is_some() {
if auth.port_part().is_some() { // std::uri::Authority::Uri
return Err(::error::Parse::Uri.into());
}
auth
Expand Down
7 changes: 4 additions & 3 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ where C: Connect + Sync + 'static,
format!("{}://{}", scheme, auth)
}
(None, Some(auth)) if is_http_connect => {
let scheme = match auth.port() {
Some(443) => {
let port = auth.port_part().unwrap();
let scheme = match port.as_str() {
"443" => {
set_scheme(req.uri_mut(), Scheme::HTTPS);
"https"
},
Expand Down Expand Up @@ -278,7 +279,7 @@ where C: Connect + Sync + 'static,
.expect("HOST is always valid header name")
.or_insert_with(|| {
let hostname = uri.host().expect("authority implies host");
if let Some(port) = uri.port() {
if let Some(port) = uri.port_part() {
let s = format!("{}:{}", hostname, port);
HeaderValue::from_str(&s)
} else {
Expand Down

0 comments on commit 69368f4

Please sign in to comment.