Skip to content

Commit 21740ef

Browse files
committed
chore(tls): Refactor tls alpn protocol check
1 parent eeb3268 commit 21740ef

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
@@ -82,10 +82,8 @@ impl TlsConnector {
8282
// explicitly set `assume_http2` to true, we'll allow it to be missing.
8383
let (_, session) = io.get_ref();
8484
let alpn_protocol = session.alpn_protocol();
85-
if alpn_protocol != Some(ALPN_H2) {
86-
if alpn_protocol.is_some() || !self.assume_http2 {
87-
return Err(TlsError::H2NotNegotiated.into());
88-
}
85+
if !(alpn_protocol == Some(ALPN_H2) || self.assume_http2) {
86+
return Err(TlsError::H2NotNegotiated.into());
8987
}
9088
Ok(BoxedIo::new(io))
9189
}

0 commit comments

Comments
 (0)