File tree 4 files changed +40
-17
lines changed
4 files changed +40
-17
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ before_script:
20
20
21
21
script :
22
22
- cargo test
23
+ - cargo test --all-features
24
+ - cargo test --no-default-features
23
25
- bash -c 'if [[ "$TRAVIS_RUST_VERSION" == "$CLIPPY_RUST_VERSION" ]]; then
24
26
cargo clippy -- -D warnings;
25
27
fi'
Original file line number Diff line number Diff line change @@ -10,15 +10,29 @@ repository = "https://github.com/ctz/hyper-rustls"
10
10
11
11
[dependencies ]
12
12
bytes = " 0.4"
13
- ct-logs = " 0.5"
13
+ ct-logs = { version = " 0.5" , optional = true }
14
14
futures = " 0.1.21"
15
- hyper = " 0.12.14"
15
+ hyper = { version = " 0.12.14" , default-features = false }
16
16
rustls = " 0.15"
17
17
tokio-io = " 0.1.1"
18
18
tokio-rustls = " 0.9"
19
19
webpki = " 0.19.0"
20
- webpki-roots = " 0.16"
20
+ webpki-roots = { version = " 0.16" , optional = true }
21
21
22
22
[dev-dependencies ]
23
23
tokio = " 0.1"
24
24
tokio-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;
2
1
use futures:: { Future , Poll } ;
3
2
use hyper:: client:: connect:: { self , Connect } ;
3
+ #[ cfg( feature = "tokio-runtime" ) ]
4
4
use hyper:: client:: HttpConnector ;
5
5
use rustls:: { ClientConfig , Session } ;
6
6
use std:: sync:: Arc ;
7
7
use std:: { fmt, io} ;
8
8
use tokio_rustls:: TlsConnector ;
9
9
use webpki:: { DNSName , DNSNameRef } ;
10
- use webpki_roots;
11
10
12
11
use stream:: MaybeHttpsStream ;
13
12
@@ -18,11 +17,15 @@ pub struct HttpsConnector<T> {
18
17
tls_config : Arc < ClientConfig > ,
19
18
}
20
19
20
+ #[ cfg( feature = "tokio-runtime" ) ]
21
21
impl HttpsConnector < HttpConnector > {
22
22
/// Construct a new `HttpsConnector`.
23
23
///
24
24
/// Takes number of DNS worker threads.
25
25
pub fn new ( threads : usize ) -> Self {
26
+ use ct_logs;
27
+ use webpki_roots;
28
+
26
29
let mut http = HttpConnector :: new ( threads) ;
27
30
http. enforce_http ( false ) ;
28
31
let mut config = ClientConfig :: new ( ) ;
Original file line number Diff line number Diff line change 5
5
//! ## Example
6
6
//!
7
7
//! ```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() {
12
13
//! use hyper::{Body, Client, StatusCode, Uri};
13
14
//!
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);
18
18
//!
19
- //! let client: Client<_, hyper::Body> = Client::builder().build(https);
19
+ //! let client: Client<_, hyper::Body> = Client::builder().build(https);
20
20
//!
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() {}
24
26
//! ```
25
27
26
28
extern crate bytes;
29
+ #[ cfg( feature = "tokio-runtime" ) ]
27
30
extern crate ct_logs;
28
31
extern crate futures;
29
32
extern crate hyper;
30
33
extern crate rustls;
31
34
extern crate tokio_io;
32
35
extern crate tokio_rustls;
33
36
extern crate webpki;
37
+ #[ cfg( feature = "tokio-runtime" ) ]
34
38
extern crate webpki_roots;
35
39
36
40
mod connector;
You can’t perform that action at this time.
0 commit comments