diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 77d9454..b00de50 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -54,8 +54,7 @@ jobs: - name: Pin dependencies for MSRV if: matrix.rust.version == '1.63.0' run: | - cargo update -p reqwest --precise "0.12.4" - cargo update -p minreq --precise "2.13.2" + cargo update -p async-minreq --precise "2.0.0" cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5" cargo update -p time --precise "0.3.20" cargo update -p home --precise "0.5.5" diff --git a/Cargo.toml b/Cargo.toml index 4d676cb..7a7a262 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ bitcoin = { version = "0.32", features = ["serde", "std"], default-features = fa hex = { version = "0.2", package = "hex-conservative" } log = "^0.4" minreq = { version = "2.11.0", features = ["json-using-serde"], optional = true } -reqwest = { version = "0.12", features = ["json"], default-features = false, optional = true } +async-minreq = { version = "0.12", features = ["json"], default-features = false, optional = true } # default async runtime tokio = { version = "1", features = ["time"], optional = true } @@ -42,8 +42,8 @@ blocking-https-native = ["blocking", "minreq/https-native"] blocking-https-bundled = ["blocking", "minreq/https-bundled"] tokio = ["dep:tokio"] -async = ["reqwest", "reqwest/socks", "tokio?/time"] -async-https = ["async", "reqwest/default-tls"] -async-https-native = ["async", "reqwest/native-tls"] -async-https-rustls = ["async", "reqwest/rustls-tls"] -async-https-rustls-manual-roots = ["async", "reqwest/rustls-tls-manual-roots"] +async = ["async-minreq", "tokio?/time"] +async-https = ["async", "async-minreq"] +async-https-native = ["async", "async-minreq"] +async-https-rustls = ["async", "async-minreq"] +async-https-rustls-manual-roots = ["async", "async-minreq"] diff --git a/README.md b/README.md index 670daf3..7432203 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This library should compile with any combination of features with Rust 1.63.0. To build with the MSRV you will need to pin dependencies as follows: ```shell -cargo update -p reqwest --precise "0.12.4" +cargo update -p async-minreq --precise "0.12.4" cargo update -p minreq --precise "2.13.2" cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5" cargo update -p time --precise "0.3.20" diff --git a/src/async.rs b/src/async.rs index b72988b..da33378 100644 --- a/src/async.rs +++ b/src/async.rs @@ -9,7 +9,7 @@ // You may not use this file except in accordance with one or both of these // licenses. -//! Esplora by way of `reqwest` HTTP client. +//! Esplora by way of `async-minreq` HTTP client. use std::collections::HashMap; use std::marker::PhantomData; @@ -26,7 +26,7 @@ use bitcoin::{ #[allow(unused_imports)] use log::{debug, error, info, trace}; -use reqwest::{header, Client, Response}; +use async-minreq::{header, Client, Response}; use crate::api::AddressStats; use crate::{ @@ -38,7 +38,7 @@ use crate::{ pub struct AsyncClient { /// The URL of the Esplora Server. url: String, - /// The inner [`reqwest::Client`] to make HTTP requests. + /// The inner [`async-minreq::Client`] to make HTTP requests. client: Client, /// Number of times to retry a request max_retries: usize, @@ -54,7 +54,7 @@ impl AsyncClient { #[cfg(not(target_arch = "wasm32"))] if let Some(proxy) = &builder.proxy { - client_builder = client_builder.proxy(reqwest::Proxy::all(proxy)?); + client_builder = client_builder.proxy(async-minreq::Proxy::all(proxy)?); } #[cfg(not(target_arch = "wasm32"))] @@ -153,7 +153,7 @@ impl AsyncClient { }); } - response.json::().await.map_err(Error::Reqwest) + response.json::().await.map_err(Error::async-minreq) } /// Make an HTTP GET request to given URL, deserializing to `Option`. @@ -478,7 +478,7 @@ impl AsyncClient { } } -fn is_status_retryable(status: reqwest::StatusCode) -> bool { +fn is_status_retryable(status: async-minreq::StatusCode) -> bool { RETRYABLE_ERROR_CODES.contains(&status.as_u16()) } diff --git a/src/lib.rs b/src/lib.rs index 5c48318..58f304d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ //! async Esplora client to query Esplora's backend. //! //! The library provides the possibility to build a blocking -//! client using [`minreq`] and an async client using [`reqwest`]. +//! client using [`minreq`] and an async client using [`async-minreq`]. //! The library supports communicating to Esplora via a proxy //! and also using TLS (SSL) for secure communication. //! @@ -53,14 +53,14 @@ //! capabilities using the platform's native TLS backend (likely OpenSSL). //! * `blocking-https-bundled` enables [`minreq`], the blocking client with proxy and TLS (SSL) //! capabilities using a bundled OpenSSL library backend. -//! * `async` enables [`reqwest`], the async client with proxy capabilities. -//! * `async-https` enables [`reqwest`], the async client with support for proxying and TLS (SSL) -//! using the default [`reqwest`] TLS backend. -//! * `async-https-native` enables [`reqwest`], the async client with support for proxying and TLS +//! * `async` enables [`async-minreq`], the async client with proxy capabilities. +//! * `async-https` enables [`async-minreq`], the async client with support for proxying and TLS (SSL) +//! using the default [`async-minreq`] TLS backend. +//! * `async-https-native` enables [`async-minreq`], the async client with support for proxying and TLS //! (SSL) using the platform's native TLS backend (likely OpenSSL). -//! * `async-https-rustls` enables [`reqwest`], the async client with support for proxying and TLS +//! * `async-https-rustls` enables [`async-minreq`], the async client with support for proxying and TLS //! (SSL) using the `rustls` TLS backend. -//! * `async-https-rustls-manual-roots` enables [`reqwest`], the async client with support for +//! * `async-https-rustls-manual-roots` enables [`async-minreq`], the async client with support for //! proxying and TLS (SSL) using the `rustls` TLS backend without using its the default root //! certificates. @@ -123,7 +123,7 @@ pub struct Builder { /// /// Note that the format of this value and the supported protocols change /// slightly between the blocking version of the client (using `minreq`) - /// and the async version (using `reqwest`). For more details check with + /// and the async version (using `async-minreq`). For more details check with /// the documentation of the two crates. Both of them are compiled with /// the `socks` feature enabled. /// @@ -200,9 +200,9 @@ pub enum Error { /// Error during `minreq` HTTP request #[cfg(feature = "blocking")] Minreq(::minreq::Error), - /// Error during reqwest HTTP request + /// Error during async-minreq HTTP request #[cfg(feature = "async")] - Reqwest(::reqwest::Error), + async-minreq(::async-minreq::Error), /// HTTP response error HttpResponse { status: u16, message: String }, /// Invalid number returned @@ -252,7 +252,7 @@ impl std::error::Error for Error {} #[cfg(feature = "blocking")] impl_error!(::minreq::Error, Minreq, Error); #[cfg(feature = "async")] -impl_error!(::reqwest::Error, Reqwest, Error); +impl_error!(::async-minreq::Error, async-minreq, Error); impl_error!(std::num::ParseIntError, Parsing, Error); impl_error!(bitcoin::consensus::encode::Error, BitcoinEncoding, Error); impl_error!(bitcoin::hex::HexToArrayError, HexToArray, Error);