Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,49 @@ targets = ["x86_64-unknown-linux-gnu"]
[features]
default = ["webpki-roots", "charset", "system-proxy"]

websocket = ["dep:tokio-tungstenite"]

# Enable HTTP/1 and HTTP/2 support.
charset = ["dep:encoding_rs", "dep:mime"]

# Enable cookies store support.
cookies = ["dep:cookie_crate", "dep:cookie_store"]

# Enable gzip compression support.
gzip = ["tower-http/decompression-gzip"]

# Enable Brotli compression support.
brotli = ["tower-http/decompression-br"]

# Enable Zstandard compression support.
zstd = ["tower-http/decompression-zstd"]

# Enable deflate compression support.
deflate = ["tower-http/decompression-deflate"]

# Enable JSON support.
json = ["dep:serde_json"]

# Enable multipart/form-data support.
multipart = ["dep:mime_guess"]

# Enable hickory DNS resolver.
hickory-dns = ["dep:hickory-resolver"]

# Enable streaming support.
stream = ["tokio/fs", "dep:tokio-util"]

# Enable socks4 and socks5 proxy support.
socks = ["dep:tokio-socks"]

# Enable HTTP/1 and HTTP/2 WebSocket support.
ws = ["dep:tokio-tungstenite"]

# Enable webpki-roots for TLS certificate validation.
webpki-roots = ["dep:webpki-root-certs"]

# Use the system's proxy configuration.
system-proxy = ["dep:system-configuration", "dep:windows-registry"]

# Optional enable tracing
# Enable tracing logging.
tracing = ["http2/tracing", "dep:tracing"]

[dependencies]
Expand Down Expand Up @@ -273,12 +286,12 @@ required-features = ["tracing"]
[[example]]
name = "http1_websocket"
path = "examples/http1_websocket.rs"
required-features = ["websocket", "futures-util/std", "tracing"]
required-features = ["ws", "futures-util/std", "tracing"]

[[example]]
name = "http2_websocket"
path = "examples/http2_websocket.rs"
required-features = ["websocket", "futures-util/std", "tracing"]
required-features = ["ws", "futures-util/std", "tracing"]

[[example]]
name = "keylog"
Expand Down
8 changes: 4 additions & 4 deletions src/client/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use {super::layer::cookie::CookieManagerLayer, crate::cookie};
feature = "deflate",
))]
use super::layer::decoder::{AcceptEncoding, DecompressionLayer};
#[cfg(feature = "websocket")]
#[cfg(feature = "ws")]
use super::ws::WebSocketRequestBuilder;
use super::{
Body, EmulationFactory,
Expand Down Expand Up @@ -326,7 +326,7 @@ impl ClientBuilder {
builder.build(connector)
};

let service = {
let client = {
let service = ClientService {
Comment thread
0x676e67 marked this conversation as resolved.
client,
config: Arc::new(ClientConfig {
Expand Down Expand Up @@ -410,7 +410,7 @@ impl ClientBuilder {
};

Ok(Client {
inner: Arc::new(service),
inner: Arc::new(client),
})
}

Expand Down Expand Up @@ -1453,7 +1453,7 @@ impl Client {
/// this after you set up your request, and just before you send the
/// request.
#[inline]
#[cfg(feature = "websocket")]
#[cfg(feature = "ws")]
pub fn websocket<U: IntoUrl>(&self, url: U) -> WebSocketRequestBuilder {
WebSocketRequestBuilder::new(self.request(Method::GET, url))
}
Expand Down
26 changes: 14 additions & 12 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
mod emulation;
mod http;
mod response;
mod upgrade;

pub(crate) mod layer;
pub(crate) mod request;

pub mod body;
#[cfg(feature = "multipart")]
pub mod multipart;
#[cfg(feature = "ws")]
pub mod ws;

pub use self::{
body::Body,
emulation::{Emulation, EmulationFactory},
Expand All @@ -6,15 +20,3 @@ pub use self::{
response::Response,
upgrade::Upgraded,
};

pub mod body;
mod emulation;
mod http;
pub(crate) mod layer;
#[cfg(feature = "multipart")]
pub mod multipart;
pub(crate) mod request;
mod response;
mod upgrade;
#[cfg(feature = "websocket")]
pub mod ws;
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@
//! The following are a list of [Cargo features][cargo-features] that can be
//! enabled or disabled:
//!
//! - **websocket**: Provides websocket support.
//! - **cookies**: Provides cookie session support.
//! - **gzip**: Provides response body gzip decompression.
//! - **brotli**: Provides response body brotli decompression.
Expand All @@ -259,6 +258,7 @@
//! - **charset** *(enabled by default)*: Improved support for decoding text.
//! - **stream**: Adds support for `futures::Stream`.
//! - **socks**: Provides SOCKS5 and SOCKS4 proxy support.
//! - **ws**: Provides websocket support.
//! - **hickory-dns**: Enables a hickory-dns async resolver instead of default threadpool using
//! `getaddrinfo`.
//! - **webpki-roots** *(enabled by default)*: Use the webpki-roots crate for root certificates.
Expand Down Expand Up @@ -297,7 +297,7 @@ pub use url::Url;

#[cfg(feature = "multipart")]
pub use self::client::multipart;
#[cfg(feature = "websocket")]
#[cfg(feature = "ws")]
pub use self::client::ws;
pub use self::{
client::{
Expand Down Expand Up @@ -325,13 +325,13 @@ fn _assert_impls() {

assert_send::<Request>();
assert_send::<RequestBuilder>();
#[cfg(feature = "websocket")]
#[cfg(feature = "ws")]
assert_send::<ws::WebSocketRequestBuilder>();

assert_send::<Response>();
#[cfg(feature = "websocket")]
#[cfg(feature = "ws")]
assert_send::<ws::WebSocketResponse>();
#[cfg(feature = "websocket")]
#[cfg(feature = "ws")]
assert_send::<ws::WebSocket>();

assert_send::<Error>();
Expand Down
Loading