Skip to content

Commit 2e44bea

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 2e44bea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/error.rs

+9
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ 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+
if matches!(self.inner.kind, Kind::Shutdown) {
245+
return true;
246+
}
247+
false
248+
}
249+
241250
/// Returns true if the error was caused by a timeout.
242251
pub fn is_timeout(&self) -> bool {
243252
#[cfg(all(feature = "http1", feature = "server"))]

0 commit comments

Comments
 (0)