File tree Expand file tree Collapse file tree 4 files changed +40
-17
lines changed Expand file tree Collapse file tree 4 files changed +40
-17
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ before_script:
2020
2121script :
2222 - cargo test
23+ - cargo test --all-features
24+ - cargo test --no-default-features
2325 - bash -c 'if [[ "$TRAVIS_RUST_VERSION" == "$CLIPPY_RUST_VERSION" ]]; then
2426 cargo clippy -- -D warnings;
2527 fi'
Original file line number Diff line number Diff line change @@ -10,15 +10,29 @@ repository = "https://github.com/ctz/hyper-rustls"
1010
1111[dependencies ]
1212bytes = " 0.4"
13- ct-logs = " 0.5"
13+ ct-logs = { version = " 0.5" , optional = true }
1414futures = " 0.1.21"
15- hyper = " 0.12.14"
15+ hyper = { version = " 0.12.14" , default-features = false }
1616rustls = " 0.15"
1717tokio-io = " 0.1.1"
1818tokio-rustls = " 0.9"
1919webpki = " 0.19.0"
20- webpki-roots = " 0.16"
20+ webpki-roots = { version = " 0.16" , optional = true }
2121
2222[dev-dependencies ]
2323tokio = " 0.1"
2424tokio-tcp = " 0.1"
25+
26+ [features ]
27+ default = [" tokio-runtime" ]
28+ tokio-runtime = [" hyper/runtime" , " ct-logs" , " webpki-roots" ]
29+
30+ [[example ]]
31+ name = " client"
32+ path = " examples/client.rs"
33+ required-features = [" tokio-runtime" ]
34+
35+ [[example ]]
36+ name = " server"
37+ path = " examples/server.rs"
38+ required-features = [" tokio-runtime" ]
Original file line number Diff line number Diff line change 1- use ct_logs;
21use futures:: { Future , Poll } ;
32use hyper:: client:: connect:: { self , Connect } ;
3+ #[ cfg( feature = "tokio-runtime" ) ]
44use hyper:: client:: HttpConnector ;
55use rustls:: { ClientConfig , Session } ;
66use std:: sync:: Arc ;
77use std:: { fmt, io} ;
88use tokio_rustls:: TlsConnector ;
99use webpki:: { DNSName , DNSNameRef } ;
10- use webpki_roots;
1110
1211use stream:: MaybeHttpsStream ;
1312
@@ -18,11 +17,15 @@ pub struct HttpsConnector<T> {
1817 tls_config : Arc < ClientConfig > ,
1918}
2019
20+ #[ cfg( feature = "tokio-runtime" ) ]
2121impl 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 ( ) ;
Original file line number Diff line number Diff line change 55//! ## Example
66//!
77//! ```no_run
8- //! extern crate hyper;
9- //! extern crate hyper_rustls;
10- //! extern crate tokio;
11- //!
8+ //! # #[cfg(feature = "tokio-runtime")]
9+ //! # extern crate hyper;
10+ //! #
11+ //! # #[cfg(feature = "tokio-runtime")]
12+ //! # fn main() {
1213//! use hyper::{Body, Client, StatusCode, Uri};
1314//!
14- //! fn main() {
15- //! let mut rt = tokio::runtime::Runtime::new().unwrap();
16- //! let url = ("https://hyper.rs").parse().unwrap();
17- //! let https = hyper_rustls::HttpsConnector::new(4);
15+ //! let mut rt = tokio::runtime::Runtime::new().unwrap();
16+ //! let url = ("https://hyper.rs").parse().unwrap();
17+ //! let https = hyper_rustls::HttpsConnector::new(4);
1818//!
19- //! let client: Client<_, hyper::Body> = Client::builder().build(https);
19+ //! let client: Client<_, hyper::Body> = Client::builder().build(https);
2020//!
21- //! let res = rt.block_on(client.get(url)).unwrap();
22- //! assert_eq!(res.status(), StatusCode::OK);
23- //! }
21+ //! let res = rt.block_on(client.get(url)).unwrap();
22+ //! assert_eq!(res.status(), StatusCode::OK);
23+ //! # }
24+ //! # #[cfg(not(feature = "tokio-runtime"))]
25+ //! # fn main() {}
2426//! ```
2527
2628extern crate bytes;
29+ #[ cfg( feature = "tokio-runtime" ) ]
2730extern crate ct_logs;
2831extern crate futures;
2932extern crate hyper;
3033extern crate rustls;
3134extern crate tokio_io;
3235extern crate tokio_rustls;
3336extern crate webpki;
37+ #[ cfg( feature = "tokio-runtime" ) ]
3438extern crate webpki_roots;
3539
3640mod connector;
You can’t perform that action at this time.
0 commit comments