Skip to content

Commit

Permalink
feat(ffi): add HYPERE_INVALID_PEER_MESSAGE error code for parse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jan 20, 2021
1 parent 237b2ce commit 1928682
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions capi/include/hyper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions src/ffi/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =====
Expand All @@ -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
Expand Down

0 comments on commit 1928682

Please sign in to comment.