Skip to content

Commit 223edef

Browse files
committed
feat(error): add 'Error::is_parse_version_h2' method
The method returns true if the underlying error is a parse error caused by HTTP2 preface sent over an HTTP1 connection.
1 parent 1c70fab commit 223edef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/error.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ impl Error {
192192
matches!(self.inner.kind, Kind::Parse(Parse::Status))
193193
}
194194

195+
/// Returns true if this was an HTTP parse error caused by HTTP2 preface sent over an HTTP1
196+
/// connection.
197+
#[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))]
198+
pub fn is_parse_version_h2(&self) -> bool {
199+
matches!(self.inner.kind, Kind::Parse(Parse::VersionH2))
200+
}
201+
195202
/// Returns true if this error was caused by user code.
196203
pub fn is_user(&self) -> bool {
197204
matches!(self.inner.kind, Kind::User(_))

0 commit comments

Comments
 (0)