diff --git a/Cargo.toml b/Cargo.toml index c97f581508..d5453f3d01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ tokio = { version = "1", features = ["sync"] } futures-channel = { version = "0.3", optional = true } futures-util = { version = "0.3", default-features = false, optional = true } -h2 = { version = "0.4.2", optional = true } +h2 = { version = "0.4.9", optional = true } http-body-util = { version = "0.1", optional = true } httparse = { version = "1.9", optional = true } httpdate = { version = "1.0", optional = true } diff --git a/src/proto/h2/server.rs b/src/proto/h2/server.rs index a8a20dd68e..bc997670b4 100644 --- a/src/proto/h2/server.rs +++ b/src/proto/h2/server.rs @@ -189,6 +189,19 @@ where } } } + + /// Checks if handshaking has completed + pub(crate) fn has_handshake_completed(&self) -> bool { + matches!(self.state, State::Serving { .. }) + } + + /// Checks if there are any streams + pub(crate) fn has_streams(&self) -> bool { + match self.state { + State::Handshaking { .. } => false, + State::Serving(ref srv) => srv.conn.has_streams(), + } + } } impl Future for Server diff --git a/src/server/conn/http2.rs b/src/server/conn/http2.rs index e0d61c13a6..6161aed652 100644 --- a/src/server/conn/http2.rs +++ b/src/server/conn/http2.rs @@ -78,6 +78,16 @@ where pub fn graceful_shutdown(mut self: Pin<&mut Self>) { self.conn.graceful_shutdown(); } + + /// Checks if handshaking has completed + pub fn has_handshake_completed(&self) -> bool { + self.conn.has_handshake_completed() + } + + /// Checks if there are any streams + pub fn has_streams(&self) -> bool { + self.conn.has_streams() + } } impl Future for Connection