From 83dad03a817f4cd25d1556ea568945c6bb35339b Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 22 Jan 2019 15:02:23 -0800 Subject: [PATCH] test(client): update tests for http::Uri::host fix --- Cargo.toml | 2 +- src/client/connect/mod.rs | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c56f79e9..23958120 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/client/connect/mod.rs b/src/client/connect/mod.rs index 57fd12f9..764835cf 100644 --- a/src/client/connect/mod.rs +++ b/src/client/connect/mod.rs @@ -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("") } @@ -93,10 +92,7 @@ impl Destination { /// Get the port, if specified. #[inline] pub fn port(&self) -> Option { - match self.uri.port_part() { - Some(port) => Some(port.as_u16()), - None => None - } + self.uri.port_u16() } /// Update the scheme of this destination. @@ -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); // ----------------- @@ -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)); }