Skip to content

Commit

Permalink
test(client): update tests for http::Uri::host fix
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jan 22, 2019
1 parent c69d109 commit 83dad03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include = [
bytes = "0.4.4"
futures = "0.1.21"
futures-cpupool = { version = "0.1.6", optional = true }
http = "0.1.14"
http = "0.1.15"
httparse = "1.0"
h2 = "0.1.10"
iovec = "0.1"
Expand Down
16 changes: 6 additions & 10 deletions src/client/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ impl Destination {
#[inline]
pub fn scheme(&self) -> &str {
self.uri
.scheme_part()
.map(|s| s.as_str())
.scheme_str()
.unwrap_or("")
}

Expand All @@ -93,10 +92,7 @@ impl Destination {
/// Get the port, if specified.
#[inline]
pub fn port(&self) -> Option<u16> {
match self.uri.port_part() {
Some(port) => Some(port.as_u16()),
None => None
}
self.uri.port_u16()
}

/// Update the scheme of this destination.
Expand Down Expand Up @@ -439,12 +435,12 @@ mod tests {

// Allow IPv6 hosts
dst.set_host("[::1]").expect("set_host with IPv6");
assert_eq!(dst.host(), "::1");
assert_eq!(dst.host(), "[::1]");
assert_eq!(dst.port(), None, "IPv6 didn't affect port");

// However, IPv6 with a port is rejected.
dst.set_host("[::2]:1337").expect_err("set_host with IPv6 and sneaky port");
assert_eq!(dst.host(), "::1");
assert_eq!(dst.host(), "[::1]");
assert_eq!(dst.port(), None);

// -----------------
Expand Down Expand Up @@ -482,12 +478,12 @@ mod tests {

// Allow IPv6 hosts
dst.set_host("[::1]").expect("set_host with IPv6");
assert_eq!(dst.host(), "::1");
assert_eq!(dst.host(), "[::1]");
assert_eq!(dst.port(), Some(8080), "IPv6 didn't affect port");

// However, IPv6 with a port is rejected.
dst.set_host("[::2]:1337").expect_err("set_host with IPv6 and sneaky port");
assert_eq!(dst.host(), "::1");
assert_eq!(dst.host(), "[::1]");
assert_eq!(dst.port(), Some(8080));
}

Expand Down

0 comments on commit 83dad03

Please sign in to comment.