Skip to content

Commit

Permalink
fix(connect): not negotiate h2 when using native-tls backend
Browse files Browse the repository at this point in the history
  • Loading branch information
cxw620 committed Mar 11, 2024
1 parent e319263 commit 2674588
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,25 +807,41 @@ mod native_tls_conn {

impl Connection for NativeTlsConn<TokioIo<TokioIo<TcpStream>>> {
fn connected(&self) -> Connected {
self.inner
let connected = self
.inner
.inner()
.get_ref()
.get_ref()
.get_ref()
.inner()
.connected()
.connected();
#[cfg(feature = "native-tls-alpn")]
match self.inner.inner().get_ref().negotiated_alpn().ok() {
Some(Some(alpn_protocol)) if alpn_protocol == b"h2" => connected.negotiated_h2(),
_ => connected,
}
#[cfg(not(feature = "native-tls-alpn"))]
connected
}
}

impl Connection for NativeTlsConn<TokioIo<MaybeHttpsStream<TokioIo<TcpStream>>>> {
fn connected(&self) -> Connected {
self.inner
let connected = self
.inner
.inner()
.get_ref()
.get_ref()
.get_ref()
.inner()
.connected()
.connected();
#[cfg(feature = "native-tls-alpn")]
match self.inner.inner().get_ref().negotiated_alpn().ok() {
Some(Some(alpn_protocol)) if alpn_protocol == b"h2" => connected.negotiated_h2(),
_ => connected,
}
#[cfg(not(feature = "native-tls-alpn"))]
connected
}
}

Expand Down

0 comments on commit 2674588

Please sign in to comment.