1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-10-05 17:52:14 +00: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"] default = ["session", "brotli", "flate2-c"]
# tls # tls
tls = ["native-tls"] tls = ["native-tls", "tokio-tls"]
# openssl # openssl
alpn = ["openssl", "tokio-openssl"] alpn = ["openssl", "tokio-openssl"]
@ -104,6 +104,7 @@ tokio-reactor = "0.1"
# native-tls # native-tls
native-tls = { version="0.2", optional = true } native-tls = { version="0.2", optional = true }
tokio-tls = { version="0.2", optional = true }
# openssl # openssl
openssl = { version="0.10", optional = true } openssl = { version="0.10", optional = true }

View file

@ -22,9 +22,9 @@ use openssl::ssl::{Error as OpensslError, SslConnector, SslMethod};
use tokio_openssl::SslConnectorExt; use tokio_openssl::SslConnectorExt;
#[cfg(all(feature = "tls", not(feature = "alpn")))] #[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")))] #[cfg(all(feature = "tls", not(feature = "alpn")))]
use tokio_tls::TlsConnectorExt; use tokio_tls::{TlsConnector, TlsStream};
#[cfg( #[cfg(
all( all(
@ -301,14 +301,14 @@ impl Default for ClientConnector {
#[cfg(all(feature = "tls", not(feature = "alpn")))] #[cfg(all(feature = "tls", not(feature = "alpn")))]
{ {
let (tx, rx) = mpsc::unbounded(); let (tx, rx) = mpsc::unbounded();
let builder = TlsConnector::builder().unwrap(); let builder = NativeTlsConnector::builder();
ClientConnector { ClientConnector {
stats: ClientConnectorStats::default(), stats: ClientConnectorStats::default(),
subscriber: None, subscriber: None,
acq_tx: tx, acq_tx: tx,
acq_rx: Some(rx), acq_rx: Some(rx),
resolver: None, resolver: None,
connector: builder.build().unwrap(), connector: builder.build().unwrap().into(),
conn_lifetime: Duration::from_secs(75), conn_lifetime: Duration::from_secs(75),
conn_keep_alive: Duration::from_secs(15), conn_keep_alive: Duration::from_secs(15),
limit: 100, limit: 100,
@ -822,7 +822,7 @@ impl ClientConnector {
if conn.0.ssl { if conn.0.ssl {
fut::Either::A( fut::Either::A(
act.connector act.connector
.connect_async(&conn.0.host, stream) .connect(&conn.0.host, stream)
.into_actor(act) .into_actor(act)
.then(move |res, _, _| { .then(move |res, _, _| {
match res { match res {
@ -1342,3 +1342,23 @@ impl AsyncWrite for Connection {
self.stream.shutdown() 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")] #[cfg(feature = "tls")]
extern crate native_tls; extern crate native_tls;
#[cfg(feature = "tls")]
extern crate tokio_tls;
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
extern crate openssl; extern crate openssl;