diff --git a/capi/include/hyper.h b/capi/include/hyper.h index 78934710af..cfc14a25fa 100644 --- a/capi/include/hyper.h +++ b/capi/include/hyper.h @@ -54,6 +54,10 @@ typedef enum { An optional hyper feature was not enabled. */ HYPERE_FEATURE_NOT_ENABLED, + /* + The peer sent an HTTP message that could not be parsed. + */ + HYPERE_INVALID_PEER_MESSAGE, } hyper_code; typedef enum { diff --git a/src/ffi/error.rs b/src/ffi/error.rs index 5dfca54ea9..eb563a60d5 100644 --- a/src/ffi/error.rs +++ b/src/ffi/error.rs @@ -20,6 +20,8 @@ pub enum hyper_code { /// An optional hyper feature was not enabled. #[cfg_attr(feature = "http2", allow(unused))] HYPERE_FEATURE_NOT_ENABLED, + /// The peer sent an HTTP message that could not be parsed. + HYPERE_INVALID_PEER_MESSAGE, } // ===== impl hyper_error ===== @@ -30,6 +32,7 @@ impl hyper_error { use crate::error::User; match self.0.kind() { + ErrorKind::Parse(_) => hyper_code::HYPERE_INVALID_PEER_MESSAGE, ErrorKind::IncompleteMessage => hyper_code::HYPERE_UNEXPECTED_EOF, ErrorKind::User(User::AbortedByCallback) => hyper_code::HYPERE_ABORTED_BY_CALLBACK, // TODO: add more variants