Skip to content

Commit

Permalink
refactor: Remove reqwest related features
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo committed Mar 15, 2024
1 parent 48235d5 commit 1a1c7ff
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 136 deletions.
108 changes: 4 additions & 104 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 4 additions & 12 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ default-members = ["."]
members = [".", "fuzz", "edge/*", "benches/vs_*"]

[features]
default = ["rustls", "services-memory"]
default = ["services-memory"]

# Build test utils or not.
#
Expand All @@ -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"]
Expand Down Expand Up @@ -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 }
12 changes: 10 additions & 2 deletions core/src/docs/upgrade.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 3 additions & 18 deletions core/src/raw/http_util/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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)
})?,
})
}
Expand All @@ -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)
})?,
})
}
Expand Down

0 comments on commit 1a1c7ff

Please sign in to comment.