diff --git a/Cargo.lock b/Cargo.lock index 5ec5dc79..dd2e398c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,6 +136,12 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -340,7 +346,7 @@ dependencies = [ "base64 0.22.1", "ether", "futures", - "http 0.2.12", + "http", "itertools", "js-sys", "jsonpath_lib", @@ -775,16 +781,16 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "h2" -version = "0.3.26" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", - "http 0.2.12", + "http", "indexmap", "slab", "tokio", @@ -848,17 +854,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.1.0" @@ -870,17 +865,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -888,7 +872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http", ] [[package]] @@ -899,8 +883,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", ] @@ -922,30 +906,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "hyper" -version = "0.14.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.4.1" @@ -955,27 +915,32 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", - "http-body 1.0.1", + "h2", + "http", + "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", "smallvec", "tokio", + "want", ] [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", - "hyper 0.14.30", + "http-body-util", + "hyper", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", ] [[package]] @@ -985,12 +950,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", + "futures-channel", "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "hyper 1.4.1", + "http", + "http-body", + "hyper", "pin-project-lite", + "socket2", "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -1427,9 +1397,11 @@ dependencies = [ "futures", "futures-timer", "hdrhistogram", - "http 0.2.12", - "hyper 0.14.30", + "http", + "http-body-util", + "hyper", "hyper-tls", + "hyper-util", "itertools", "json_env_logger", "log", @@ -1447,11 +1419,32 @@ dependencies = [ "test_common", "tokio", "tokio-stream", + "tokio-util", "url", "yansi", "zip_all", ] +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -1853,9 +1846,9 @@ dependencies = [ "bytes", "futures", "futures-timer", - "http 1.1.0", + "http", "http-body-util", - "hyper 1.4.1", + "hyper", "hyper-util", "log", "parking_lot", @@ -1963,6 +1956,27 @@ dependencies = [ "tokio", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + [[package]] name = "tower-service" version = "0.3.2" diff --git a/Cargo.toml b/Cargo.toml index 5ad4cb0f..73351ebc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,9 +32,11 @@ for_each_parallel = { path = "./lib/for_each_parallel" } futures = "0.3" futures-timer = "3" hdrhistogram = "7" -http = "0.2" -hyper = { version = "0.14", features = ["client", "http1", "http2", "stream"] } -hyper-tls = "0.5" +http = "1.1" +hyper = { version = "1.0", features = ["client", "http1", "http2"] } +hyper-tls = "0.6" +hyper-util = { version = "0.1", features = ["tokio", "client", "http1", "http2"] } +http-body-util = "0.1" itertools = "0.13" mod_interval = { path = "./lib/mod_interval" } native-tls = "0.2" @@ -47,6 +49,7 @@ serde_json = "1" test_common = { path = "./lib/test_common" } tokio = "1" tokio-stream = { version = "0.1", features = ["sync", "time"] } +tokio-util = "0.7" url = "2" yansi = "1" zip_all = { path = "./lib/zip_all" } diff --git a/lib/config/Cargo.toml b/lib/config/Cargo.toml index a2f98c13..f395bb51 100644 --- a/lib/config/Cargo.toml +++ b/lib/config/Cargo.toml @@ -12,7 +12,7 @@ doctest = false base64 = "0.22" ether = { path = "../either" } futures = "0.3" -http = "0.2" +http = "1.1" itertools = "0.13" jsonpath_lib = "0.3.0" percent-encoding = "2" diff --git a/lib/test_common/Cargo.toml b/lib/test_common/Cargo.toml index 99d73946..7828fbbc 100644 --- a/lib/test_common/Cargo.toml +++ b/lib/test_common/Cargo.toml @@ -13,8 +13,8 @@ path = "test_common.rs" bytes = "1" futures = "0.3" futures-timer = "3" -hyper = { version = "1.4", features = ["http1"] } -hyper-util = { version = "0.1", features = ["tokio", "server", "http1"] } +hyper = { version = "1.4", features = ["http1", "http2"] } +hyper-util = { version = "0.1", features = ["tokio", "server", "http1", "http2"] } http = "1.1" http-body-util = "0.1" parking_lot = "0.12" diff --git a/src/lib.rs b/src/lib.rs index 7c1235b0..287170f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,8 +26,15 @@ use futures::{ stream, FutureExt, Stream, StreamExt, }; use futures_timer::Delay; -use hyper::{client::HttpConnector, Body, Client}; +use hyper::body::Incoming as Body; use hyper_tls::HttpsConnector; +use hyper_util::{ + client::legacy::{ + connect::{dns::GaiResolver, HttpConnector}, + Client, + }, + rt::TokioExecutor, +}; use itertools::Itertools; use line_writer::{blocking_writer, MsgType}; use log::{debug, error, info, warn}; @@ -1139,16 +1146,15 @@ fn create_load_test_future( pub(crate) fn create_http_client( keepalive: Duration, -) -> Result< - Client>>, - TestError, -> { +) -> Result>, Body>, TestError> { let mut http = HttpConnector::new(); http.set_keepalive(Some(keepalive)); http.set_reuse_address(true); http.enforce_http(false); let https = HttpsConnector::from((http, TlsConnector::new()?.into())); - Ok(Client::builder().set_host(false).build::<_, Body>(https)) + Ok(Client::builder(TokioExecutor::new()) + .set_host(false) + .build::<_, Body>(https)) } type ProvidersResult = Result<(BTreeMap, BTreeSet), TestError>; diff --git a/src/request/request_maker.rs b/src/request/request_maker.rs index 5864d89d..883b503e 100644 --- a/src/request/request_maker.rs +++ b/src/request/request_maker.rs @@ -12,11 +12,15 @@ use futures::{ }; use futures_timer::Delay; use hyper::{ - client::HttpConnector, + body::Incoming, header::{HeaderMap, HeaderName, HeaderValue, CONTENT_LENGTH, CONTENT_TYPE, HOST}, - Client, Method, Request, + Method, Request, }; use hyper_tls::HttpsConnector; +use hyper_util::client::legacy::{ + connect::{dns::GaiResolver, HttpConnector}, + Client, +}; use log::{debug, info}; use serde_json as json; @@ -41,8 +45,7 @@ pub(super) struct RequestMaker { pub(super) headers: Vec<(String, Template)>, pub(super) body: BodyTemplate, pub(super) rr_providers: u16, - pub(super) client: - Arc>>>, + pub(super) client: Arc>, Incoming>>, pub(super) stats_tx: StatsTx, pub(super) no_auto_returns: bool, pub(super) outgoing: Arc>, @@ -279,21 +282,7 @@ impl RequestMaker { request.headers_mut().extend(headers); let mut response_future = client.request(request).map_err(|e| { - let err: Arc = if let Some(io_error_maybe) = e.source() - { - if io_error_maybe.downcast_ref::().is_some() { - let io_error = e.into_cause().expect("should have a cause error"); - Arc::new( - *io_error - .downcast::() - .expect("should downcast as io error"), - ) - } else { - Arc::new(e) - } - } else { - Arc::new(e) - }; + let err: Arc = Arc::new(e); TestError::from(RecoverableError::ConnectionErr(SystemTime::now(), err)) }); let outgoing2 = outgoing.clone();