From 46508d1b4f6dd85cb54a576fa6ef84abc007f559 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Wed, 20 Mar 2024 20:00:35 +0000 Subject: [PATCH] Update reqwest Signed-off-by: Nikolaos Karaolidis --- Cargo.lock | 61 ++++++++++++++++--------------- Cargo.toml | 3 +- src/bin/qrust/routes/assets.rs | 14 +------ src/lib/qrust/alpaca/mod.rs | 2 +- src/lib/qrust/alpaca/positions.rs | 3 +- 5 files changed, 38 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4610d6c..b2411bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,7 +254,7 @@ dependencies = [ "clickhouse-rs-cityhash-sys", "futures", "hyper 0.14.28", - "hyper-tls", + "hyper-tls 0.5.0", "lz4", "sealed", "serde", @@ -636,25 +636,6 @@ dependencies = [ "spinning_top", ] -[[package]] -name = "h2" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap 2.2.5", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "h2" version = "0.4.3" @@ -791,7 +772,6 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.25", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -814,7 +794,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.3", + "h2", "http 1.1.0", "http-body 1.0.0", "httparse", @@ -823,6 +803,7 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", + "want", ] [[package]] @@ -838,6 +819,22 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.2.0", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.3" @@ -845,6 +842,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ "bytes", + "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", @@ -852,6 +850,9 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -1453,20 +1454,22 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.27" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "58b48d98d932f4ee75e541614d32a7f44c889b72bd9c2e04d95edd135989df88" dependencies = [ "base64", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.3.25", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", - "hyper-tls", + "h2", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-tls 0.6.0", + "hyper-util", "ipnet", "js-sys", "log", diff --git a/Cargo.toml b/Cargo.toml index c084066..ce1bd61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,9 +38,8 @@ serde_repr = "0.1.18" serde_with = "3.6.1" serde-aux = "4.4.0" futures-util = "0.3.28" -reqwest = { version = "0.11.20", features = [ +reqwest = { version = "0.12.0", features = [ "json", - "serde_json", ] } http = "1.0.0" governor = "0.6.0" diff --git a/src/bin/qrust/routes/assets.rs b/src/bin/qrust/routes/assets.rs index 113afdd..7fae89b 100644 --- a/src/bin/qrust/routes/assets.rs +++ b/src/bin/qrust/routes/assets.rs @@ -81,12 +81,7 @@ pub async fn add( &ALPACA_API_BASE, ) .await - .map_err(|e| { - e.status() - .map_or(StatusCode::INTERNAL_SERVER_ERROR, |status| { - StatusCode::from_u16(status.as_u16()).unwrap() - }) - })? + .map_err(|e| e.status().unwrap_or(StatusCode::INTERNAL_SERVER_ERROR))? .into_iter() .map(|asset| (asset.symbol.clone(), asset)) .collect::>(); @@ -158,12 +153,7 @@ pub async fn add_symbol( &ALPACA_API_BASE, ) .await - .map_err(|e| { - e.status() - .map_or(StatusCode::INTERNAL_SERVER_ERROR, |status| { - StatusCode::from_u16(status.as_u16()).unwrap() - }) - })?; + .map_err(|e| e.status().unwrap_or(StatusCode::INTERNAL_SERVER_ERROR))?; if asset.status != types::alpaca::api::incoming::asset::Status::Active || !asset.tradable diff --git a/src/lib/qrust/alpaca/mod.rs b/src/lib/qrust/alpaca/mod.rs index 26d431e..9dc24b5 100644 --- a/src/lib/qrust/alpaca/mod.rs +++ b/src/lib/qrust/alpaca/mod.rs @@ -7,7 +7,7 @@ pub mod news; pub mod orders; pub mod positions; -use reqwest::StatusCode; +use http::StatusCode; pub fn error_to_backoff(err: reqwest::Error) -> backoff::Error { if err.is_status() { diff --git a/src/lib/qrust/alpaca/positions.rs b/src/lib/qrust/alpaca/positions.rs index 143826c..8f4afd0 100644 --- a/src/lib/qrust/alpaca/positions.rs +++ b/src/lib/qrust/alpaca/positions.rs @@ -2,6 +2,7 @@ use super::error_to_backoff; use crate::types::alpaca::api::incoming::position::Position; use backoff::{future::retry_notify, ExponentialBackoff}; use governor::DefaultDirectRateLimiter; +use http::StatusCode; use log::warn; use reqwest::Client; use std::{collections::HashSet, time::Duration}; @@ -58,7 +59,7 @@ pub async fn get_by_symbol( .await .map_err(error_to_backoff)?; - if response.status() == reqwest::StatusCode::NOT_FOUND { + if response.status() == StatusCode::NOT_FOUND { return Ok(None); }