Skip to content

Commit

Permalink
fix(connect): not negotiate h2 when using native-tls backend (#2165)
Browse files Browse the repository at this point in the history
  • Loading branch information
cxw620 authored Mar 22, 2024
1 parent e0ea15b commit 056f8c4
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 @@ -811,25 +811,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 056f8c4

Please sign in to comment.