Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ default = []
full = [
"client",
"client-legacy",
"client-legacy-http-connector",
"client-pool",
"client-proxy",
"client-proxy-system",
Expand All @@ -79,7 +80,8 @@ full = [
]

client = ["hyper/client", "dep:tracing", "dep:futures-channel", "dep:tower-service"]
client-legacy = ["client", "tokio/net", "dep:socket2", "tokio/sync", "dep:libc", "dep:futures-util", "dep:httparse", "dep:sync_wrapper"]
client-legacy = ["client", "tokio/sync", "dep:futures-util", "dep:httparse", "dep:sync_wrapper"]
client-legacy-http-connector = ["dep:libc", "dep:socket2", "tokio/net"]
client-pool = ["client", "dep:futures-util", "dep:tower-layer", "tokio/sync"]
client-proxy = ["client", "dep:base64", "dep:ipnet", "dep:percent-encoding"]
client-proxy-system = ["dep:system-configuration", "dep:windows-registry"]
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
check-client-features:
cargo hack --no-dev-deps check --feature-powerset --depth 2 \
--features=client \
--include-features client-legacy,client-pool,client-proxy,client-proxy-system,http1,http2,tokio,tracing
--include-features client-legacy,client-legacy-http-connector,client-pool,client-proxy,client-proxy-system,http1,http2,tokio,tracing

check-server-features:
cargo hack --no-dev-deps check --feature-powerset --depth 2 \
Expand Down
4 changes: 2 additions & 2 deletions src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use hyper::{Method, Request, Response, Uri, Version, body::Body};
use sync_wrapper::SyncWrapper;
use tracing::{debug, trace, warn};

#[cfg(feature = "tokio")]
#[cfg(all(feature = "client-legacy-http-connector", feature = "tokio"))]
use super::connect::HttpConnector;
use super::connect::capture::CaptureConnectionExtension;
use super::connect::{Alpn, Connect, Connected, Connection};
Expand Down Expand Up @@ -1616,7 +1616,7 @@ impl Builder {
}

/// Build a client with this configuration and the default `HttpConnector`.
#[cfg(feature = "tokio")]
#[cfg(all(feature = "client-legacy-http-connector", feature = "tokio"))]
pub fn build_http<B>(&self) -> Client<HttpConnector, B>
where
B: Body + Send,
Expand Down
9 changes: 8 additions & 1 deletion src/client/legacy/connect/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! });
//! ```
use std::error::Error;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
use std::net::{SocketAddr, ToSocketAddrs};
use std::pin::Pin;
use std::str::FromStr;
use std::task::{self, Poll};
Expand All @@ -30,6 +30,10 @@ use std::{fmt, io, vec};
use tokio::task::JoinHandle;
use tower_service::Service;

#[cfg(feature = "client-legacy-http-connector")]
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6};

#[cfg(feature = "client-legacy-http-connector")]
pub(super) use self::sealed::Resolve;

/// A domain name to resolve into IP addresses.
Expand Down Expand Up @@ -179,6 +183,7 @@ pub(super) struct SocketAddrs {
iter: vec::IntoIter<SocketAddr>,
}

#[cfg(feature = "client-legacy-http-connector")]
impl SocketAddrs {
pub(super) fn new(addrs: Vec<SocketAddr>) -> Self {
SocketAddrs {
Expand Down Expand Up @@ -249,6 +254,7 @@ impl Iterator for SocketAddrs {
}
}

#[cfg(all(feature = "client-legacy-http-connector"))]
mod sealed {
use std::task::{self, Poll};

Expand Down Expand Up @@ -285,6 +291,7 @@ mod sealed {
}
}

#[cfg(feature = "client-legacy-http-connector")]
pub(super) async fn resolve<R>(resolver: &mut R, name: Name) -> Result<R::Addrs, R::Error>
where
R: Resolve,
Expand Down
4 changes: 2 additions & 2 deletions src/client/legacy/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures_util::future::Either;
use http::uri::{Scheme, Uri};
use pin_project_lite::pin_project;
use socket2::TcpKeepalive;
use tokio::net::{TcpSocket, TcpStream};
use tokio::net::TcpStream;
use tokio::time::Sleep;
use tracing::{debug, trace, warn};

Expand Down Expand Up @@ -941,7 +941,7 @@ fn connect(
.map_err(ConnectError::m("tcp bind local error"))?;

// Convert the `Socket` to a Tokio `TcpSocket`.
let socket = TcpSocket::from_std_stream(socket.into());
let socket = tokio::net::TcpSocket::from_std_stream(socket.into());

if config.reuse_address {
if let Err(e) = socket.set_reuseaddr(true) {
Expand Down
7 changes: 4 additions & 3 deletions src/client/legacy/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
//! This module contains:
//!
//! - A default [`HttpConnector`][] that does DNS resolution and establishes
//! connections over TCP.
//! connections over TCP. This connector is gated behind the
//! `client-legacy-http-connector` feature flag.
//! - Types to build custom connectors.
//!
//! # Connectors
Expand Down Expand Up @@ -72,12 +73,12 @@ use std::{

use ::http::Extensions;

#[cfg(feature = "tokio")]
#[cfg(all(feature = "client-legacy-http-connector", feature = "tokio"))]
pub use self::http::{HttpConnector, HttpInfo};

#[cfg(feature = "tokio")]
pub mod dns;
#[cfg(feature = "tokio")]
#[cfg(all(feature = "client-legacy-http-connector", feature = "tokio"))]
mod http;

pub mod proxy;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
//! * `client`: Enable [`client`] interfaces.
//! * `client-legacy`: Enable the legacy
//! [`Client`][crate::client::legacy::Client] implementation.
//! * `client-legacy-http-connector`: Enable the legacy
//! [`HttpConnector`][crate::client::legacy::connect::HttpConnector].
//! * `client-pool`: Enable [`client::pool`]. This submodule contains
//! interfaces for constructing connection pools.
//! * `client-proxy`: Enable [`client::proxy`].
Expand Down
Loading