Skip to content

Commit 4eb1854

Browse files
committed
Optionally disable pulling in the tokio runtime
Before this patch, hyper-rustls required pulling in the tokio runtime due to it's use of `hyper::client::HttpConnector`. Unfortunately Fuchsia does not support tokio, which prevents our use of this library. This PR allows us to optionally disable pulling in tokio, and instead swap in our own version of the hyper `HttpConnector`.
1 parent 8925936 commit 4eb1854

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ repository = "https://github.com/ctz/hyper-rustls"
1010

1111
[dependencies]
1212
bytes = "0.4"
13-
ct-logs = "0.5"
13+
ct-logs = { version = "0.5", optional = true }
1414
futures = "0.1.21"
15-
hyper = "0.12.14"
15+
hyper = { version = "0.12.14", default-features = false }
1616
rustls = "0.15"
1717
tokio-io = "0.1.1"
1818
tokio-rustls = "0.9"
1919
webpki = "0.19.0"
20-
webpki-roots = "0.16"
20+
webpki-roots = { version = "0.16", optional = true }
2121

2222
[dev-dependencies]
2323
tokio = "0.1"
2424
tokio-tcp = "0.1"
25+
26+
[features]
27+
default = ["tokio-runtime"]
28+
tokio-runtime = ["hyper/runtime", "ct-logs", "webpki-roots"]

src/connector.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
use ct_logs;
21
use futures::{Future, Poll};
32
use hyper::client::connect::{self, Connect};
3+
#[cfg(feature = "tokio-runtime")]
44
use hyper::client::HttpConnector;
55
use rustls::{ClientConfig, Session};
66
use std::sync::Arc;
77
use std::{fmt, io};
88
use tokio_rustls::TlsConnector;
99
use webpki::{DNSName, DNSNameRef};
10-
use webpki_roots;
1110

1211
use stream::MaybeHttpsStream;
1312

@@ -18,11 +17,15 @@ pub struct HttpsConnector<T> {
1817
tls_config: Arc<ClientConfig>,
1918
}
2019

20+
#[cfg(feature = "tokio-runtime")]
2121
impl HttpsConnector<HttpConnector> {
2222
/// Construct a new `HttpsConnector`.
2323
///
2424
/// Takes number of DNS worker threads.
2525
pub fn new(threads: usize) -> Self {
26+
use ct_logs;
27+
use webpki_roots;
28+
2629
let mut http = HttpConnector::new(threads);
2730
http.enforce_http(false);
2831
let mut config = ClientConfig::new();

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
//! ```
2525
2626
extern crate bytes;
27+
#[cfg(feature = "tokio-runtime")]
2728
extern crate ct_logs;
2829
extern crate futures;
2930
extern crate hyper;
3031
extern crate rustls;
3132
extern crate tokio_io;
3233
extern crate tokio_rustls;
3334
extern crate webpki;
35+
#[cfg(feature = "tokio-runtime")]
3436
extern crate webpki_roots;
3537

3638
mod connector;

0 commit comments

Comments
 (0)