diff --git a/Cargo.lock b/Cargo.lock index bce09ddd5c..56d6e769de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1373,7 +1373,6 @@ dependencies = [ "fluence-libp2p", "fs-utils", "futures", - "hyper", "libp2p", "log", "maplit", @@ -1381,6 +1380,7 @@ dependencies = [ "particle-args", "particle-execution", "particle-protocol", + "reqwest", "serde", "serde_json", "server-config", @@ -1780,6 +1780,15 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + [[package]] name = "enum-as-inner" version = "0.6.0" @@ -2098,6 +2107,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.0" @@ -2677,6 +2701,19 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -4438,6 +4475,24 @@ dependencies = [ "unsigned-varint 0.7.2", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -4560,7 +4615,6 @@ dependencies = [ "futures", "health", "humantime-serde", - "hyper", "itertools 0.11.0", "kademlia", "key-manager", @@ -4584,6 +4638,7 @@ dependencies = [ "peer-metrics", "prometheus-client", "rand 0.8.5", + "reqwest", "serde", "serde_json", "server-config", @@ -4749,12 +4804,50 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" +dependencies = [ + "bitflags 2.4.1", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "opentelemetry" version = "0.21.0" @@ -5766,6 +5859,44 @@ dependencies = [ "winapi", ] +[[package]] +name = "reqwest" +version = "0.11.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +dependencies = [ + "base64 0.21.5", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -6904,6 +7035,16 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -7363,6 +7504,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vec_map" version = "0.8.2" @@ -7531,6 +7678,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.88" diff --git a/Cargo.toml b/Cargo.toml index 6d67346ad2..2551847e37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -143,7 +143,7 @@ humantime-serde = "1.1.1" cid = "0.11.0" libipld = "0.16.0" axum = "0.6.20" -hyper = "0.14.27" +reqwest = "0.11.12" faster-hex = "0.8.1" once_cell = "1.18.0" diff --git a/crates/created-swarm/Cargo.toml b/crates/created-swarm/Cargo.toml index 9c9e52631e..b2de015829 100644 --- a/crates/created-swarm/Cargo.toml +++ b/crates/created-swarm/Cargo.toml @@ -35,4 +35,4 @@ serde_json = { workspace = true } base64 = { workspace = true } serde = { workspace = true } maplit = { workspace = true } -hyper = { workspace = true } +reqwest = { workspace = true } diff --git a/crates/created-swarm/src/swarm.rs b/crates/created-swarm/src/swarm.rs index 9bfee43298..ba8e6057e3 100644 --- a/crates/created-swarm/src/swarm.rs +++ b/crates/created-swarm/src/swarm.rs @@ -34,7 +34,6 @@ use fluence_libp2p::Transport; use fs_utils::{create_dir, make_tmp_dir_peer_id, to_abs_path}; use futures::future::join_all; use futures::stream::iter; -use hyper::{Body, Request, StatusCode}; use nox::{Connectivity, Node}; use particle_protocol::ProtocolConfig; use server_config::{system_services_config, BootstrapConfig, UnresolvedConfig}; @@ -205,21 +204,17 @@ where } async fn wait_connected_on_addrs(addrs: Vec) { - let http_client = &hyper::Client::new(); + let http_client = &reqwest::Client::new(); let healthcheck = iter(addrs).for_each_concurrent(None, |addr| async move { loop { let response = http_client - .request( - Request::builder() - .uri(format!("http://{}/health", addr)) - .body(Body::empty()) - .unwrap(), - ) + .get(format!("http://{}/health", addr)) + .send() .await .unwrap(); - if response.status() == StatusCode::OK { + if response.status() == reqwest::StatusCode::OK { break; } diff --git a/nox/Cargo.toml b/nox/Cargo.toml index 241b67391e..23a30c7ee8 100644 --- a/nox/Cargo.toml +++ b/nox/Cargo.toml @@ -79,7 +79,8 @@ rand = "0.8.5" bs58 = { workspace = true } connected-client = { path = "../crates/connected-client" } log-utils = { workspace = true } -hyper = { workspace = true } +reqwest = { workspace = true } + [[bench]] name = "network_api_bench" diff --git a/nox/src/http.rs b/nox/src/http.rs index f3c7c21def..57842bdc91 100644 --- a/nox/src/http.rs +++ b/nox/src/http.rs @@ -145,7 +145,6 @@ pub async fn start_http_endpoint( #[cfg(test)] mod tests { use super::*; - use axum::http::Request; use health::HealthCheck; use std::net::SocketAddr; @@ -183,19 +182,15 @@ mod tests { let http_info = notify_receiver.await.unwrap(); - let client = hyper::Client::new(); + let client = reqwest::Client::new(); let response = client - .request( - Request::builder() - .uri(format!("http://{}/versions", http_info.listen_addr)) - .body(Body::empty()) - .unwrap(), - ) + .get(format!("http://{}/versions", http_info.listen_addr)) + .send() .await .unwrap(); let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + let body = response.bytes().await.unwrap(); assert_eq!(status, StatusCode::OK); assert_eq!(&body[..], br#"{"node":"node_test_version","avm":"avm_test_version","spell":"spell_test_version","aqua_ipfs":"aqua_ipfs_test_version","trust_graph":"trust_graph_test_version","registry":"registry_test_version","decider":"decider_test_version"}"#); } @@ -213,19 +208,15 @@ mod tests { let http_info = notify_receiver.await.unwrap(); - let client = hyper::Client::new(); + let client = reqwest::Client::new(); let response = client - .request( - Request::builder() - .uri(format!("http://{}/peer_id", http_info.listen_addr)) - .body(Body::empty()) - .unwrap(), - ) + .get(format!("http://{}/peer_id", http_info.listen_addr)) + .send() .await .unwrap(); let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + let body = response.bytes().await.unwrap(); assert_eq!(status, StatusCode::OK); assert_eq!( &body[..], @@ -255,19 +246,15 @@ mod tests { let http_info = notify_receiver.await.unwrap(); - let client = hyper::Client::new(); + let client = reqwest::Client::new(); let response = client - .request( - Request::builder() - .uri(format!("http://{}/health", http_info.listen_addr)) - .body(Body::empty()) - .unwrap(), - ) + .get(format!("http://{}/health", http_info.listen_addr)) + .send() .await .unwrap(); let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + let body = response.bytes().await.unwrap(); assert_eq!(status, StatusCode::OK); assert_eq!(&body[..], (r#"[]"#).as_bytes()); } @@ -302,19 +289,15 @@ mod tests { let http_info = notify_receiver.await.unwrap(); - let client = hyper::Client::new(); + let client = reqwest::Client::new(); let response = client - .request( - Request::builder() - .uri(format!("http://{}/health", http_info.listen_addr)) - .body(Body::empty()) - .unwrap(), - ) + .get(format!("http://{}/health", http_info.listen_addr)) + .send() .await .unwrap(); let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + let body = response.bytes().await.unwrap(); assert_eq!(status, StatusCode::OK); assert_eq!(&body[..], (r#"[{"test_check":"Ok"}]"#).as_bytes()); } @@ -357,19 +340,15 @@ mod tests { let http_info = notify_receiver.await.unwrap(); - let client = hyper::Client::new(); + let client = reqwest::Client::new(); let response = client - .request( - Request::builder() - .uri(format!("http://{}/health", http_info.listen_addr)) - .body(Body::empty()) - .unwrap(), - ) + .get(format!("http://{}/health", http_info.listen_addr)) + .send() .await .unwrap(); let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + let body = response.bytes().await.unwrap(); assert_eq!(status, StatusCode::TOO_MANY_REQUESTS); assert_eq!( &body[..], @@ -407,19 +386,15 @@ mod tests { let http_info = notify_receiver.await.unwrap(); - let client = hyper::Client::new(); + let client = reqwest::Client::new(); let response = client - .request( - Request::builder() - .uri(format!("http://{}/health", http_info.listen_addr)) - .body(Body::empty()) - .unwrap(), - ) + .get(format!("http://{}/health", http_info.listen_addr)) + .send() .await .unwrap(); let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + let body = response.bytes().await.unwrap(); assert_eq!(status, StatusCode::SERVICE_UNAVAILABLE); assert_eq!(&body[..], (r#"[{"test_check":"Fail"}]"#).as_bytes()); }