Skip to content

Commit f86fd98

Browse files
authored
Revert "Upgrade to tokio-native-tls (#65)" (#73)
This reverts commit 7c9adcd.
1 parent 1e14d7a commit f86fd98

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bytes = "0.5"
1818
native-tls = "0.2"
1919
hyper = { version = "0.13", default-features = false, features = ["tcp"] }
2020
tokio = { version = "0.2" }
21-
tokio-native-tls = "0.1"
21+
tokio-tls = "0.3"
2222

2323
[dev-dependencies]
2424
tokio = { version = "0.2", features = ["io-std", "macros"] }

src/client.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::task::{Context, Poll};
55

66
use hyper::{client::connect::HttpConnector, service::Service, Uri};
77
use tokio::io::{AsyncRead, AsyncWrite};
8-
use tokio_native_tls::TlsConnector;
8+
use tokio_tls::TlsConnector;
99

1010
use crate::stream::MaybeHttpsStream;
1111

@@ -65,18 +65,13 @@ impl<T> HttpsConnector<T> {
6565
pub fn https_only(&mut self, enable: bool) {
6666
self.force_https = enable;
6767
}
68-
68+
6969
/// With connector constructor
70-
///
70+
///
7171
pub fn new_with_connector(http: T) -> Self {
7272
native_tls::TlsConnector::new()
7373
.map(|tls| HttpsConnector::from((http, tls.into())))
74-
.unwrap_or_else(|e| {
75-
panic!(
76-
"HttpsConnector::new_with_connector(<connector>) failure: {}",
77-
e
78-
)
79-
})
74+
.unwrap_or_else(|e| panic!("HttpsConnector::new_with_connector(<connector>) failure: {}", e))
8075
}
8176
}
8277

@@ -131,7 +126,9 @@ where
131126
let fut = async move {
132127
let tcp = connecting.await.map_err(Into::into)?;
133128
let maybe = if is_https {
134-
let tls = tls.connect(&host, tcp).await?;
129+
let tls = tls
130+
.connect(&host, tcp)
131+
.await?;
135132
MaybeHttpsStream::Https(tls)
136133
} else {
137134
MaybeHttpsStream::Http(tcp)
@@ -146,7 +143,8 @@ fn err<T>(e: BoxError) -> HttpsConnecting<T> {
146143
HttpsConnecting(Box::pin(async { Err(e) }))
147144
}
148145

149-
type BoxedFut<T> = Pin<Box<dyn Future<Output = Result<MaybeHttpsStream<T>, BoxError>> + Send>>;
146+
type BoxedFut<T> =
147+
Pin<Box<dyn Future<Output = Result<MaybeHttpsStream<T>, BoxError>> + Send>>;
150148

151149
/// A Future representing work to connect to a URL, and a TLS handshake.
152150
pub struct HttpsConnecting<T>(BoxedFut<T>);

src/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::task::{Context, Poll};
66
use bytes::{Buf, BufMut};
77
use hyper::client::connect::{Connected, Connection};
88
use tokio::io::{AsyncRead, AsyncWrite};
9-
pub use tokio_native_tls::TlsStream;
9+
pub use tokio_tls::TlsStream;
1010

1111
/// A stream that might be protected with TLS.
1212
pub enum MaybeHttpsStream<T> {
@@ -119,7 +119,7 @@ impl<T: AsyncRead + AsyncWrite + Connection + Unpin> Connection for MaybeHttpsSt
119119
fn connected(&self) -> Connected {
120120
match self {
121121
MaybeHttpsStream::Http(s) => s.connected(),
122-
MaybeHttpsStream::Https(s) => s.get_ref().get_ref().get_ref().connected(),
122+
MaybeHttpsStream::Https(s) => s.get_ref().connected(),
123123
}
124124
}
125125
}

0 commit comments

Comments
 (0)