You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/03/15 06:17:43 UTC
(opendal) branch fix-http-client created (now 1a1c7fffaf)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a change to branch fix-http-client
in repository https://gitbox.apache.org/repos/asf/opendal.git
at 1a1c7fffaf refactor: Remove reqwest related features
This branch includes the following new commits:
new 1a1c7fffaf refactor: Remove reqwest related features
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(opendal) 01/01: refactor: Remove reqwest related features
Posted by xu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch fix-http-client
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 1a1c7fffaf152d127f48cdcb6b5a04daea27840f
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Fri Mar 15 14:17:17 2024 +0800
refactor: Remove reqwest related features
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
core/Cargo.lock | 108 ++-------------------------------------
core/Cargo.toml | 16 ++----
core/src/docs/upgrade.md | 12 ++++-
core/src/raw/http_util/client.rs | 21 ++------
4 files changed, 21 insertions(+), 136 deletions(-)
diff --git a/core/Cargo.lock b/core/Cargo.lock
index 5986d5cae1..91a83648fb 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -2118,18 +2118,6 @@ dependencies = [
"syn 1.0.109",
]
-[[package]]
-name = "enum-as-inner"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a"
-dependencies = [
- "heck",
- "proc-macro2",
- "quote",
- "syn 2.0.48",
-]
-
[[package]]
name = "equivalent"
version = "1.0.1"
@@ -2984,19 +2972,6 @@ 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.59"
@@ -3037,16 +3012,6 @@ dependencies = [
"unicode-normalization",
]
-[[package]]
-name = "idna"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
-dependencies = [
- "unicode-bidi",
- "unicode-normalization",
-]
-
[[package]]
name = "idna"
version = "0.5.0"
@@ -3789,8 +3754,8 @@ dependencies = [
"tokio",
"tokio-rustls",
"tokio-util",
- "trust-dns-proto 0.21.2",
- "trust-dns-resolver 0.21.2",
+ "trust-dns-proto",
+ "trust-dns-resolver",
"typed-builder",
"uuid",
"webpki-roots 0.25.4",
@@ -4302,15 +4267,6 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
-[[package]]
-name = "openssl-src"
-version = "300.2.2+3.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8bbfad0063610ac26ee79f7484739e2b07555a75c42453b89263830b5c8103bc"
-dependencies = [
- "cc",
-]
-
[[package]]
name = "openssl-sys"
version = "0.9.99"
@@ -4319,7 +4275,6 @@ checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae"
dependencies = [
"cc",
"libc",
- "openssl-src",
"pkg-config",
"vcpkg",
]
@@ -5378,36 +5333,27 @@ dependencies = [
"http 0.2.11",
"http-body",
"hyper",
- "hyper-rustls",
- "hyper-tls",
"ipnet",
"js-sys",
"log",
"mime",
- "native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls",
- "rustls-native-certs",
- "rustls-pemfile",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
- "tokio-native-tls",
- "tokio-rustls",
"tokio-util",
"tower-service",
- "trust-dns-resolver 0.23.2",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-streams",
"web-sys",
- "webpki-roots 0.25.4",
"winreg",
]
@@ -6869,7 +6815,7 @@ dependencies = [
"async-trait",
"cfg-if",
"data-encoding",
- "enum-as-inner 0.4.0",
+ "enum-as-inner",
"futures-channel",
"futures-io",
"futures-util",
@@ -6885,31 +6831,6 @@ dependencies = [
"url",
]
-[[package]]
-name = "trust-dns-proto"
-version = "0.23.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3119112651c157f4488931a01e586aa459736e9d6046d3bd9105ffb69352d374"
-dependencies = [
- "async-trait",
- "cfg-if",
- "data-encoding",
- "enum-as-inner 0.6.0",
- "futures-channel",
- "futures-io",
- "futures-util",
- "idna 0.4.0",
- "ipnet",
- "once_cell",
- "rand 0.8.5",
- "smallvec",
- "thiserror",
- "tinyvec",
- "tokio",
- "tracing",
- "url",
-]
-
[[package]]
name = "trust-dns-resolver"
version = "0.21.2"
@@ -6927,28 +6848,7 @@ dependencies = [
"smallvec",
"thiserror",
"tokio",
- "trust-dns-proto 0.21.2",
-]
-
-[[package]]
-name = "trust-dns-resolver"
-version = "0.23.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10a3e6c3aff1718b3c73e395d1f35202ba2ffa847c6a62eea0db8fb4cfe30be6"
-dependencies = [
- "cfg-if",
- "futures-util",
- "ipconfig",
- "lru-cache",
- "once_cell",
- "parking_lot 0.12.1",
- "rand 0.8.5",
- "resolv-conf",
- "smallvec",
- "thiserror",
- "tokio",
- "tracing",
- "trust-dns-proto 0.23.2",
+ "trust-dns-proto",
]
[[package]]
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 6d7a8d25b0..72a90cffaf 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -39,7 +39,7 @@ default-members = ["."]
members = [".", "fuzz", "edge/*", "benches/vs_*"]
[features]
-default = ["rustls", "services-memory"]
+default = ["services-memory"]
# Build test utils or not.
#
@@ -59,17 +59,6 @@ tests = [
"services-s3",
]
-# Enable trust-dns for pure rust dns cache.
-trust-dns = ["reqwest/trust-dns"]
-
-# Enable rustls for TLS support
-rustls = ["reqwest/rustls-tls-native-roots"]
-rustls-webpki = ["reqwest/rustls-tls-webpki-roots"]
-# Enable native-tls for TLS support
-native-tls = ["reqwest/native-tls"]
-# Enable vendored native-tls for TLS support
-native-tls-vendored = ["reqwest/native-tls-vendored"]
-
# Enable path cache.
# This is an internal feature, and should not be used by users.
internal-path-cache = ["dep:moka"]
@@ -388,3 +377,6 @@ tracing-subscriber = { version = "0.3", features = [
"tracing-log",
] }
wiremock = "0.5"
+reqwest = { version = "0.11.18", features = [
+ "stream", "rustls"
+], default-features = false }
diff --git a/core/src/docs/upgrade.md b/core/src/docs/upgrade.md
index 3ffa845444..a9bed6cf0b 100644
--- a/core/src/docs/upgrade.md
+++ b/core/src/docs/upgrade.md
@@ -1,8 +1,16 @@
# Upgrade to v0.46
-## Services Feature Flag
+## Public API
+
+### Services Feature Flag
+
+Starting with version 0.46, OpenDAL only includes the memory service by default to prevent compiling unnecessary service code. To use other services, please activate their respective feature flags.
+
+Additionally, we have removed all `reqwest`-related feature flags:
-Starting from v0.46, OpenDAL does not include any services except memory service in default features to avoid compiling unneeded services' code. Please enable each service's feature flag to use it.
+- Users must now directly use `reqwest`'s feature flags for options like `rustls`, `native-tls`, etc.
+- The `rustls` feature is no longer enabled by default; it must be activated manually.
+- OpenDAL no longer offers the `trust-dns` option; users should configure the client builder directly.
# Upgrade to v0.45
diff --git a/core/src/raw/http_util/client.rs b/core/src/raw/http_util/client.rs
index e8108e3a6a..3f2f50d675 100644
--- a/core/src/raw/http_util/client.rs
+++ b/core/src/raw/http_util/client.rs
@@ -19,7 +19,6 @@ use std::fmt::Debug;
use std::fmt::Formatter;
use std::mem;
use std::str::FromStr;
-use std::time::Duration;
use futures::TryStreamExt;
use http::Request;
@@ -34,8 +33,6 @@ use crate::Error;
use crate::ErrorKind;
use crate::Result;
-const DEFAULT_CONNECT_TIMEOUT: Duration = Duration::from_secs(60);
-
/// HttpClient that used across opendal.
#[derive(Clone)]
pub struct HttpClient {
@@ -57,22 +54,10 @@ impl HttpClient {
/// Build a new http client in async context.
#[cfg(not(target_arch = "wasm32"))]
- pub fn build(mut builder: reqwest::ClientBuilder) -> Result<Self> {
- // Make sure we don't enable auto gzip decompress.
- builder = builder.no_gzip();
- // Make sure we don't enable auto brotli decompress.
- builder = builder.no_brotli();
- // Make sure we don't enable auto deflate decompress.
- builder = builder.no_deflate();
- // Make sure we don't wait a connection establishment forever.
- builder = builder.connect_timeout(DEFAULT_CONNECT_TIMEOUT);
-
- #[cfg(feature = "trust-dns")]
- let builder = builder.trust_dns(true);
-
+ pub fn build(builder: reqwest::ClientBuilder) -> Result<Self> {
Ok(Self {
client: builder.build().map_err(|err| {
- Error::new(ErrorKind::Unexpected, "async client build failed").set_source(err)
+ Error::new(ErrorKind::Unexpected, "http client build failed").set_source(err)
})?,
})
}
@@ -82,7 +67,7 @@ impl HttpClient {
pub fn build(mut builder: reqwest::ClientBuilder) -> Result<Self> {
Ok(Self {
client: builder.build().map_err(|err| {
- Error::new(ErrorKind::Unexpected, "async client build failed").set_source(err)
+ Error::new(ErrorKind::Unexpected, "http client build failed").set_source(err)
})?,
})
}