test(client): update tests for http::Uri::host fix
This commit is contained in:
@@ -21,7 +21,7 @@ include = [
|
|||||||
bytes = "0.4.4"
|
bytes = "0.4.4"
|
||||||
futures = "0.1.21"
|
futures = "0.1.21"
|
||||||
futures-cpupool = { version = "0.1.6", optional = true }
|
futures-cpupool = { version = "0.1.6", optional = true }
|
||||||
http = "0.1.14"
|
http = "0.1.15"
|
||||||
httparse = "1.0"
|
httparse = "1.0"
|
||||||
h2 = "0.1.10"
|
h2 = "0.1.10"
|
||||||
iovec = "0.1"
|
iovec = "0.1"
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ impl Destination {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn scheme(&self) -> &str {
|
pub fn scheme(&self) -> &str {
|
||||||
self.uri
|
self.uri
|
||||||
.scheme_part()
|
.scheme_str()
|
||||||
.map(|s| s.as_str())
|
|
||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,10 +92,7 @@ impl Destination {
|
|||||||
/// Get the port, if specified.
|
/// Get the port, if specified.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn port(&self) -> Option<u16> {
|
pub fn port(&self) -> Option<u16> {
|
||||||
match self.uri.port_part() {
|
self.uri.port_u16()
|
||||||
Some(port) => Some(port.as_u16()),
|
|
||||||
None => None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the scheme of this destination.
|
/// Update the scheme of this destination.
|
||||||
@@ -439,12 +435,12 @@ mod tests {
|
|||||||
|
|
||||||
// Allow IPv6 hosts
|
// Allow IPv6 hosts
|
||||||
dst.set_host("[::1]").expect("set_host with IPv6");
|
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");
|
assert_eq!(dst.port(), None, "IPv6 didn't affect port");
|
||||||
|
|
||||||
// However, IPv6 with a port is rejected.
|
// However, IPv6 with a port is rejected.
|
||||||
dst.set_host("[::2]:1337").expect_err("set_host with IPv6 and sneaky port");
|
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);
|
assert_eq!(dst.port(), None);
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
@@ -482,12 +478,12 @@ mod tests {
|
|||||||
|
|
||||||
// Allow IPv6 hosts
|
// Allow IPv6 hosts
|
||||||
dst.set_host("[::1]").expect("set_host with IPv6");
|
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");
|
assert_eq!(dst.port(), Some(8080), "IPv6 didn't affect port");
|
||||||
|
|
||||||
// However, IPv6 with a port is rejected.
|
// However, IPv6 with a port is rejected.
|
||||||
dst.set_host("[::2]:1337").expect_err("set_host with IPv6 and sneaky port");
|
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));
|
assert_eq!(dst.port(), Some(8080));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user