Skip to content

Commit 6cc3638

Browse files
committed
feat: add Error::is_shutdown()
Benchmarking tools often cause connections to be ungracefully shutdown. This makes it possible to filter these errors out. Replaces hyperium#2745
1 parent c449528 commit 6cc3638

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/error.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,14 @@ impl Error {
238238
matches!(self.inner.kind, Kind::User(User::BodyWriteAborted))
239239
}
240240

241+
/// Returns true if the error was caused while calling `AsyncWrite::shutdown()`.
242+
pub fn is_shutdown(&self) -> bool {
243+
#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
244+
matches!(self.inner.kind, Kind::Shutdown);
245+
#[cfg(not(all(feature = "http1", any(feature = "client", feature = "server"))))]
246+
false
247+
}
248+
241249
/// Returns true if the error was caused by a timeout.
242250
pub fn is_timeout(&self) -> bool {
243251
#[cfg(all(feature = "http1", feature = "server"))]

0 commit comments

Comments
 (0)