diff --git a/src/error.rs b/src/error.rs index 8b41f9c93d..90c64008ab 100644 --- a/src/error.rs +++ b/src/error.rs @@ -192,6 +192,13 @@ impl Error { matches!(self.inner.kind, Kind::Parse(Parse::Status)) } + /// Returns true if this was an HTTP parse error caused by HTTP2 preface sent over an HTTP1 + /// connection. + #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] + pub fn is_parse_version_h2(&self) -> bool { + matches!(self.inner.kind, Kind::Parse(Parse::VersionH2)) + } + /// Returns true if this error was caused by user code. pub fn is_user(&self) -> bool { matches!(self.inner.kind, Kind::User(_)) diff --git a/src/server/conn/http1.rs b/src/server/conn/http1.rs index 36dda98069..a2fa5e1d6d 100644 --- a/src/server/conn/http1.rs +++ b/src/server/conn/http1.rs @@ -522,6 +522,12 @@ where Pin::new(conn).graceful_shutdown() } } + + /// Return the inner IO object, and additional information provided the connection + /// has not yet been upgraded. + pub fn into_parts(self) -> Option> { + self.inner.map(|conn| conn.into_parts()) + } } impl Future for UpgradeableConnection