diff --git a/Cargo.toml b/Cargo.toml index 6437ec26..bc182b16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ path = "src/lib.rs" default = ["session", "brotli", "flate2-c"] # tls -tls = ["native-tls"] +tls = ["native-tls", "tokio-tls"] # openssl alpn = ["openssl", "tokio-openssl"] @@ -104,6 +104,7 @@ tokio-reactor = "0.1" # native-tls native-tls = { version="0.2", optional = true } +tokio-tls = { version="0.2", optional = true } # openssl openssl = { version="0.10", optional = true } diff --git a/src/client/connector.rs b/src/client/connector.rs index 61347682..c0dbf85f 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -22,9 +22,9 @@ use openssl::ssl::{Error as OpensslError, SslConnector, SslMethod}; use tokio_openssl::SslConnectorExt; #[cfg(all(feature = "tls", not(feature = "alpn")))] -use native_tls::{Error as TlsError, TlsConnector, TlsStream}; +use native_tls::{Error as TlsError, TlsConnector as NativeTlsConnector}; #[cfg(all(feature = "tls", not(feature = "alpn")))] -use tokio_tls::TlsConnectorExt; +use tokio_tls::{TlsConnector, TlsStream}; #[cfg( all( @@ -301,14 +301,14 @@ impl Default for ClientConnector { #[cfg(all(feature = "tls", not(feature = "alpn")))] { let (tx, rx) = mpsc::unbounded(); - let builder = TlsConnector::builder().unwrap(); + let builder = NativeTlsConnector::builder(); ClientConnector { stats: ClientConnectorStats::default(), subscriber: None, acq_tx: tx, acq_rx: Some(rx), resolver: None, - connector: builder.build().unwrap(), + connector: builder.build().unwrap().into(), conn_lifetime: Duration::from_secs(75), conn_keep_alive: Duration::from_secs(15), limit: 100, @@ -822,7 +822,7 @@ impl ClientConnector { if conn.0.ssl { fut::Either::A( act.connector - .connect_async(&conn.0.host, stream) + .connect(&conn.0.host, stream) .into_actor(act) .then(move |res, _, _| { match res { @@ -1342,3 +1342,23 @@ impl AsyncWrite for Connection { self.stream.shutdown() } } + +#[cfg(feature = "tls")] +/// This is temp solution untile actix-net migration +impl IoStream for TlsStream { + #[inline] + fn shutdown(&mut self, _how: Shutdown) -> io::Result<()> { + let _ = self.get_mut().shutdown(); + Ok(()) + } + + #[inline] + fn set_nodelay(&mut self, nodelay: bool) -> io::Result<()> { + self.get_mut().get_mut().set_nodelay(nodelay) + } + + #[inline] + fn set_linger(&mut self, dur: Option) -> io::Result<()> { + self.get_mut().get_mut().set_linger(dur) + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 4eeb5ada..f57ab937 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -148,6 +148,8 @@ extern crate serde_derive; #[cfg(feature = "tls")] extern crate native_tls; +#[cfg(feature = "tls")] +extern crate tokio_tls; #[cfg(feature = "openssl")] extern crate openssl;