Skip to content

Commit

Permalink
change: separate out tls feature flags
Browse files Browse the repository at this point in the history
A successor to #53, this separates out the tls feature flags, which should be nicer.

Fixes: #54
  • Loading branch information
Fishrock123 committed Feb 12, 2021
1 parent 60e351b commit 3c7593f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/h1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
10 changes: 5 additions & 5 deletions src/h1/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,15 +76,15 @@ impl Manager<TlsStream<TcpStream>, 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::TlsStream<TcpStream>, async_native_tls::Error> {
) -> Result<TlsStream<TcpStream>, 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<TlsStream<TcpStream>, std::io::Error> {
let connector = async_tls::TlsConnector::default();
connector.connect(host, stream).await
Expand Down

0 comments on commit 3c7593f

Please sign in to comment.