From 3c7593f669450fcf8db368c963f634eecd0abb8c Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Thu, 11 Feb 2021 15:46:19 -0800 Subject: [PATCH] change: separate out tls feature flags A successor to https://github.com/http-rs/http-client/pull/53, this separates out the tls feature flags, which should be nicer. Fixes: https://github.com/http-rs/http-client/issues/54 --- .github/workflows/ci.yaml | 2 +- Cargo.toml | 9 ++++++--- src/h1/mod.rs | 4 ++-- src/h1/tls.rs | 10 +++++----- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9bc5e75..53d1d6d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - backend: [h1_client, hyper_client, curl_client] + backend: ["h1_client,native-tls", hyper_client, curl_client] steps: - uses: actions/checkout@master diff --git a/Cargo.toml b/Cargo.toml index c2ac196..d05e4fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,15 +20,18 @@ features = ["docs"] rustdoc-args = ["--cfg", "feature=\"docs\""] [features] -default = ["h1_client"] +default = ["h1_client", "native-tls"] docs = ["h1_client", "curl_client", "wasm_client", "hyper_client"] -h1_client = ["async-h1", "async-std", "async-native-tls", "deadpool", "futures"] -h1_client_rustls = ["async-h1", "async-std", "async-tls", "deadpool", "futures"] + +h1_client = ["async-h1", "async-std", "deadpool", "futures"] native_client = ["curl_client", "wasm_client"] curl_client = ["isahc", "async-std"] wasm_client = ["js-sys", "web-sys", "wasm-bindgen", "wasm-bindgen-futures", "futures"] hyper_client = ["hyper", "hyper-tls", "http-types/hyperium_http", "futures-util"] +native-tls = ["async-native-tls"] +rustls = ["async-tls"] + [dependencies] async-trait = "0.1.37" dashmap = "4.0.2" diff --git a/src/h1/mod.rs b/src/h1/mod.rs index 7888d79..7228b90 100644 --- a/src/h1/mod.rs +++ b/src/h1/mod.rs @@ -9,9 +9,9 @@ use dashmap::DashMap; use deadpool::managed::Pool; use http_types::StatusCode; -#[cfg(not(feature = "h1_client_rustls"))] +#[cfg(feature = "native-tls")] use async_native_tls::TlsStream; -#[cfg(feature = "h1_client_rustls")] +#[cfg(feature = "rustls")] use async_tls::client::TlsStream; use super::{async_trait, Error, HttpClient, Request, Response}; diff --git a/src/h1/tls.rs b/src/h1/tls.rs index 5a2f017..1e7ddd6 100644 --- a/src/h1/tls.rs +++ b/src/h1/tls.rs @@ -8,9 +8,9 @@ use deadpool::managed::{Manager, Object, RecycleResult}; use futures::io::{AsyncRead, AsyncWrite}; use futures::task::{Context, Poll}; -#[cfg(not(feature = "h1_client_rustls"))] +#[cfg(feature = "native-tls")] use async_native_tls::TlsStream; -#[cfg(feature = "h1_client_rustls")] +#[cfg(feature = "rustls")] use async_tls::client::TlsStream; use crate::Error; @@ -76,15 +76,15 @@ impl Manager, Error> for TlsConnection { } } -#[cfg(not(feature = "h1_client_rustls"))] +#[cfg(feature = "native-tls")] async fn add_tls( host: &str, stream: TcpStream, -) -> Result, async_native_tls::Error> { +) -> Result, async_native_tls::Error> { async_native_tls::connect(host, stream).await } -#[cfg(feature = "h1_client_rustls")] +#[cfg(feature = "rustls")] async fn add_tls(host: &str, stream: TcpStream) -> Result, std::io::Error> { let connector = async_tls::TlsConnector::default(); connector.connect(host, stream).await