Skip to content

Commit 7551d5d

Browse files
authored
chore(tls): Refactor tls alpn protocol check (#1681)
1 parent fcf7a65 commit 7551d5d

File tree

1 file changed

+2
-4
lines changed
  • tonic/src/transport/service

1 file changed

+2
-4
lines changed

tonic/src/transport/service/tls.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ impl TlsConnector {
8585
// explicitly set `assume_http2` to true, we'll allow it to be missing.
8686
let (_, session) = io.get_ref();
8787
let alpn_protocol = session.alpn_protocol();
88-
if alpn_protocol != Some(ALPN_H2) {
89-
if alpn_protocol.is_some() || !self.assume_http2 {
90-
return Err(TlsError::H2NotNegotiated.into());
91-
}
88+
if !(alpn_protocol == Some(ALPN_H2) || self.assume_http2) {
89+
return Err(TlsError::H2NotNegotiated.into());
9290
}
9391
Ok(BoxedIo::new(io))
9492
}

0 commit comments

Comments
 (0)