Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to hyper 0.12.7 to fix a keep-alive bug #26

Merged
merged 2 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "hyper"
version = "0.12.6"
version = "0.12.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -482,7 +482,7 @@ dependencies = [
"h2 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"inotify 0.5.2-dev (git+https://github.com/inotify-rs/inotify)",
"ipnet 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1585,7 +1585,7 @@ dependencies = [
"checksum hostname 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "58fab6e177434b0bb4cd344a4dabaa5bd6d7a8d792b1885aebcae7af1091d1cb"
"checksum http 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4fbced8864b04c030eebcb7d0dc3a81ba5231ac559f5116a29a8ba83ecee22cd"
"checksum httparse 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b6288d7db100340ca12873fd4d08ad1b8f206a9457798dfb17c018a33fee540"
"checksum hyper 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)" = "bd2dbf44d0eb8b32ac0cb7b0d75c31313554dd04d6f5dd1085e150ec5383d9b8"
"checksum hyper 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c087746de95e20e4dabe86606c3a019964a8fde2d5f386152939063c116c5971"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum indexmap 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9378f1f3923647a9aea6af4c6b5de68cc8a71415459ad25ef191191c48f5b7"
"checksum inotify 0.5.2-dev (git+https://github.com/inotify-rs/inotify)" = "<none>"
Expand Down
10 changes: 0 additions & 10 deletions tests/support/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ impl Server {
self
}

/// Return a 200 OK response with no body when the path matches.
pub fn route_empty_ok(self, path: &str) -> Self {
self.route_fn(path, |_| {
Response::builder()
.header("content-length", "0")
.body(Default::default())
.unwrap()
})
}

/// Call a closure when the request matches, returning a response
/// to send back.
pub fn route_fn<F>(mut self, path: &str, cb: F) -> Self
Expand Down
56 changes: 21 additions & 35 deletions tests/transparency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@ fn http1_one_connection_per_host() {
let _ = env_logger::try_init();

let srv = server::http1()
.route_empty_ok("/")
.route("/body", "hello hosts")
.route("/no-body", "")
.run();
let proxy = proxy::new().inbound(srv).run();

Expand All @@ -825,57 +826,42 @@ fn http1_one_connection_per_host() {
let inbound = &proxy.inbound_server.as_ref()
.expect("no inbound server!");

// Run each case with and without a body.
let run_request = move |host, expected_conn_cnt| {
for path in &["/no-body", "/body"][..] {
let res = client.request(client.request_builder(path)
.version(http::Version::HTTP_11)
.header("host", host)
);
assert_eq!(res.status(), http::StatusCode::OK);
assert_eq!(res.version(), http::Version::HTTP_11);
assert_eq!(inbound.connections(), expected_conn_cnt);
}
};

// Make a request with the header "Host: foo.bar". After the request, the
// server should have seen one connection.
let res1 = client.request(client.request_builder("/")
.version(http::Version::HTTP_11)
.header("host", "foo.bar")
);
assert_eq!(res1.status(), http::StatusCode::OK);
assert_eq!(res1.version(), http::Version::HTTP_11);
assert_eq!(inbound.connections(), 1);
run_request("foo.bar", 1);

// Another request with the same host. The proxy may reuse the connection.
let res1 = client.request(client.request_builder("/")
.version(http::Version::HTTP_11)
.header("host", "foo.bar")
);
assert_eq!(res1.status(), http::StatusCode::OK);
assert_eq!(res1.version(), http::Version::HTTP_11);
assert_eq!(inbound.connections(), 1);
run_request("foo.bar", 1);

// Make a request with a different Host header. This request must use a new
// connection.
let res2 = client.request(client.request_builder("/")
.version(http::Version::HTTP_11)
.header("host", "bar.baz"));
assert_eq!(res2.status(), http::StatusCode::OK);
assert_eq!(res2.version(), http::Version::HTTP_11);
assert_eq!(inbound.connections(), 2);

let res2 = client.request(client.request_builder("/")
.version(http::Version::HTTP_11)
.header("host", "bar.baz"));
assert_eq!(res2.status(), http::StatusCode::OK);
assert_eq!(res2.version(), http::Version::HTTP_11);
assert_eq!(inbound.connections(), 2);
run_request("bar.baz", 2);
run_request("bar.baz", 2);

// Make a request with a different Host header. This request must use a new
// connection.
let res3 = client.request(client.request_builder("/")
.version(http::Version::HTTP_11)
.header("host", "quuuux.com"));
assert_eq!(res3.status(), http::StatusCode::OK);
assert_eq!(res3.version(), http::Version::HTTP_11);
assert_eq!(inbound.connections(), 3);
run_request("quuuux.com", 3);
}

#[test]
fn http1_requests_without_host_have_unique_connections() {
let _ = env_logger::try_init();

let srv = server::http1()
.route_empty_ok("/")
.route("/", "unique hosts")
.run();
let proxy = proxy::new().inbound(srv).run();

Expand Down