From 2e44bea36f9ece80daf781495e4b3675a9aa571c Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Sun, 23 Mar 2025 12:04:28 -0700 Subject: [PATCH] feat: add Error::is_shutdown() Benchmarking tools often cause connections to be ungracefully shutdown. This makes it possible to filter these errors out. Replaces #2745 --- src/error.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/error.rs b/src/error.rs index 48917db970..42b684cb19 100644 --- a/src/error.rs +++ b/src/error.rs @@ -238,6 +238,15 @@ impl Error { matches!(self.inner.kind, Kind::User(User::BodyWriteAborted)) } + /// Returns true if the error was caused while calling `AsyncWrite::shutdown()`. + pub fn is_shutdown(&self) -> bool { + #[cfg(all(feature = "http1", any(feature = "client", feature = "server")))] + if matches!(self.inner.kind, Kind::Shutdown) { + return true; + } + false + } + /// Returns true if the error was caused by a timeout. pub fn is_timeout(&self) -> bool { #[cfg(all(feature = "http1", feature = "server"))]