1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 09:42:57 +01:00

fix tokio-tls dependency #480

This commit is contained in:
Nikolay Kim 2018-08-23 10:10:13 -07:00
parent 1716380f08
commit 810995ade0
3 changed files with 29 additions and 6 deletions

View File

@ -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 }

View File

@ -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<Io: IoStream> IoStream for TlsStream<Io> {
#[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<time::Duration>) -> io::Result<()> {
self.get_mut().get_mut().set_linger(dur)
}
}

View File

@ -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;