Skip to content

Commit

Permalink
fix use
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Mar 12, 2024
1 parent fde6987 commit 38deff0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,7 @@ impl ClientBuilder {
let mut tls = Some(tls);
#[cfg(feature = "native-tls")]
{
if let Some(conn) =
(&mut tls as &mut dyn Any).downcast_mut::<Option<native_tls_crate::TlsConnector>>()
{
if let Some(conn) = (&mut tls as &mut dyn Any).downcast_mut::<Option<TlsConnector>>() {
let tls = conn.take().expect("is definitely Some");
let tls = crate::tls::TlsBackend::BuiltNativeTls(tls);
self.config.tls = tls;
Expand Down
16 changes: 8 additions & 8 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use http::uri::{Authority, Scheme};
use http::Uri;
use hyper::rt::{Read, ReadBufCursor, Write};
use hyper_util::client::legacy::connect::{Connected, Connection};
#[cfg(feature = "__tls")]
#[cfg(any(feature = "socks", feature = "__rustls"))]
use hyper_util::rt::TokioIo;
#[cfg(feature = "default-tls")]
use native_tls_crate::{TlsConnector, TlsConnectorBuilder};
Expand Down Expand Up @@ -217,11 +217,11 @@ impl Connector {
if dst.scheme() == Some(&Scheme::HTTPS) {
let host = dst.host().ok_or("no host in url")?.to_string();
let conn = socks::connect(proxy, dst, dns).await?;
let conn = hyper_util::rt::TokioIo::new(conn);
let conn = hyper_util::rt::TokioIo::new(conn);
let conn = TokioIo::new(conn);
let conn = TokioIo::new(conn);
let tls_connector = tokio_native_tls::TlsConnector::from(tls.clone());
let io = tls_connector.connect(&host, conn).await?;
let io = hyper_util::rt::TokioIo::new(io);
let io = TokioIo::new(io);
return Ok(Conn {
inner: self.verbose.wrap(NativeTlsConn { inner: io }),
is_proxy: false,
Expand All @@ -238,15 +238,15 @@ impl Connector {
let tls = tls_proxy.clone();
let host = dst.host().ok_or("no host in url")?.to_string();
let conn = socks::connect(proxy, dst, dns).await?;
let conn = hyper_util::rt::TokioIo::new(conn);
let conn = hyper_util::rt::TokioIo::new(conn);
let conn = TokioIo::new(conn);
let conn = TokioIo::new(conn);
let server_name =
rustls_pki_types::ServerName::try_from(host.as_str().to_owned())
.map_err(|_| "Invalid Server Name")?;
let io = RustlsConnector::from(tls)
.connect(server_name, conn)
.await?;
let io = hyper_util::rt::TokioIo::new(io);
let io = TokioIo::new(io);
return Ok(Conn {
inner: self.verbose.wrap(RustlsTlsConn { inner: io }),
is_proxy: false,
Expand All @@ -259,7 +259,7 @@ impl Connector {
}

socks::connect(proxy, dst, dns).await.map(|tcp| Conn {
inner: self.verbose.wrap(hyper_util::rt::TokioIo::new(tcp)),
inner: self.verbose.wrap(TokioIo::new(tcp)),
is_proxy: false,
tls_info: false,
})
Expand Down
2 changes: 1 addition & 1 deletion tests/support/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Drop for Server {
pub fn http<F, Fut>(func: F) -> Server
where
F: Fn(http::Request<hyper::body::Incoming>) -> Fut + Clone + Send + 'static,
Fut: Future<Output = Response<reqwest::Body>> + Send + 'static,
Fut: Future<Output = http::Response<reqwest::Body>> + Send + 'static,
{
http_with_config(func, |_builder| {})
}
Expand Down

0 comments on commit 38deff0

Please sign in to comment.