fix(server): convert panic to error if Connection::without_shutdown called on HTTP/2 conn
This commit is contained in:
13
src/error.rs
13
src/error.rs
@@ -128,6 +128,10 @@ pub(super) enum User {
|
||||
#[cfg(feature = "http1")]
|
||||
ManualUpgrade,
|
||||
|
||||
/// User called `server::Connection::without_shutdown()` on an HTTP/2 conn.
|
||||
#[cfg(feature = "server")]
|
||||
WithoutShutdownNonHttp1,
|
||||
|
||||
/// User aborted in an FFI callback.
|
||||
#[cfg(feature = "ffi")]
|
||||
AbortedByCallback,
|
||||
@@ -355,6 +359,11 @@ impl Error {
|
||||
Error::new_user(User::Body).with(cause)
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
pub(super) fn new_without_shutdown_not_h1() -> Error {
|
||||
Error::new(Kind::User(User::WithoutShutdownNonHttp1))
|
||||
}
|
||||
|
||||
#[cfg(feature = "http1")]
|
||||
pub(super) fn new_shutdown(cause: std::io::Error) -> Error {
|
||||
Error::new(Kind::Shutdown).with(cause)
|
||||
@@ -449,6 +458,10 @@ impl Error {
|
||||
Kind::User(User::NoUpgrade) => "no upgrade available",
|
||||
#[cfg(feature = "http1")]
|
||||
Kind::User(User::ManualUpgrade) => "upgrade expected but low level API in use",
|
||||
#[cfg(feature = "server")]
|
||||
Kind::User(User::WithoutShutdownNonHttp1) => {
|
||||
"without_shutdown() called on a non-HTTP/1 connection"
|
||||
}
|
||||
#[cfg(feature = "ffi")]
|
||||
Kind::User(User::AbortedByCallback) => "operation aborted by an application callback",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user