From 1928682b33f98244435ba6d574677546205a15ec Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 20 Jan 2021 14:53:25 -0800 Subject: [PATCH] feat(ffi): add HYPERE_INVALID_PEER_MESSAGE error code for parse errors --- capi/include/hyper.h | 4 ++++ src/ffi/error.rs | 3 +++ 2 files changed, 7 insertions(+) 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