From 31c5d2dcda7400bc6af7871e98be7ac96e32506e Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Thu, 20 Jul 2023 14:23:58 +0800 Subject: [PATCH] remove http scheme check --- crates/core/src/conn/native_tls/listener.rs | 4 --- crates/core/src/conn/openssl/listener.rs | 34 +++++++++------------ crates/core/src/conn/rustls/listener.rs | 26 +++++++--------- 3 files changed, 26 insertions(+), 38 deletions(-) diff --git a/crates/core/src/conn/native_tls/listener.rs b/crates/core/src/conn/native_tls/listener.rs index 185fdf3a3..5eb19441f 100644 --- a/crates/core/src/conn/native_tls/listener.rs +++ b/crates/core/src/conn/native_tls/listener.rs @@ -163,7 +163,6 @@ where http_version, http_scheme, } = self.inner.accept().await?; - if http_scheme == Scheme::HTTPS { let conn = tls_acceptor .accept(conn) .await @@ -175,8 +174,5 @@ where http_version, http_scheme, }) - } else { - Err(IoError::new(ErrorKind::Other, "native_tls: invalid scheme.")) - } } } diff --git a/crates/core/src/conn/openssl/listener.rs b/crates/core/src/conn/openssl/listener.rs index bec401053..2562be5bd 100644 --- a/crates/core/src/conn/openssl/listener.rs +++ b/crates/core/src/conn/openssl/listener.rs @@ -163,24 +163,20 @@ where http_version, http_scheme, } = self.inner.accept().await?; - if http_scheme == Scheme::HTTPS { - let ssl = Ssl::new(tls_acceptor.context()).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?; - let mut tls_stream = - SslStream::new(ssl, conn).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?; - use std::pin::Pin; - Pin::new(&mut tls_stream) - .accept() - .await - .map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?; - Ok(Accepted { - conn: tls_stream, - local_addr, - remote_addr, - http_version, - http_scheme, - }) - } else { - Err(IoError::new(ErrorKind::Other, "openssl: invalid scheme.")) - } + let ssl = Ssl::new(tls_acceptor.context()).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?; + let mut tls_stream = + SslStream::new(ssl, conn).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?; + use std::pin::Pin; + Pin::new(&mut tls_stream) + .accept() + .await + .map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?; + Ok(Accepted { + conn: tls_stream, + local_addr, + remote_addr, + http_version, + http_scheme, + }) } } diff --git a/crates/core/src/conn/rustls/listener.rs b/crates/core/src/conn/rustls/listener.rs index 5ce785f96..dce1b7b86 100644 --- a/crates/core/src/conn/rustls/listener.rs +++ b/crates/core/src/conn/rustls/listener.rs @@ -149,20 +149,16 @@ where http_version, http_scheme, } = self.inner.accept().await?; - if http_scheme == Scheme::HTTPS { - let conn = tls_acceptor - .accept(conn) - .await - .map_err(|e| IoError::new(ErrorKind::Other, e.to_string()))?; - Ok(Accepted { - conn, - local_addr, - remote_addr, - http_version, - http_scheme, - }) - } else { - Err(IoError::new(ErrorKind::Other, "rustls: invalid scheme.")) - } + let conn = tls_acceptor + .accept(conn) + .await + .map_err(|e| IoError::new(ErrorKind::Other, e.to_string()))?; + Ok(Accepted { + conn, + local_addr, + remote_addr, + http_version, + http_scheme, + }) } }