Skip to content

Commit

Permalink
Use iana H2 error code description
Browse files Browse the repository at this point in the history
The iana h2 error code descriptions
(https://www.iana.org/assignments/http2-parameters/http2-parameters.xhtml#error-code) seem to be more comprehensive and shorter.
  • Loading branch information
eaufavor committed Nov 16, 2021
1 parent ce81583 commit 02f93c9
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/frame/reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,20 @@ impl Reason {
/// Get a string description of the error code.
pub fn description(&self) -> &str {
match self.0 {
0 => "not a result of an error",
1 => "unspecific protocol error detected",
2 => "unexpected internal error encountered",
3 => "flow-control protocol violated",
4 => "settings ACK not received in timely manner",
5 => "received frame when stream half-closed",
6 => "frame with invalid size",
7 => "refused stream before processing any application logic",
8 => "stream no longer needed",
9 => "unable to maintain the header compression context",
10 => {
"connection established in response to a CONNECT request was reset or abnormally \
closed"
}
11 => "detected excessive load generating behavior",
12 => "security properties do not meet minimum requirements",
13 => "endpoint requires HTTP/1.1",
0 => "Graceful shutdown",
1 => "Protocol error detected",
2 => "Implementation fault",
3 => "Flow-control limits exceeded",
4 => "Settings not acknowledged",
5 => "Frame received for closed stream",
6 => "Frame size incorrect",
7 => "Stream not processed",
8 => "Stream cancelled",
9 => "Compression state not updated",
10 => "TCP connection error for CONNECT method",
11 => "Processing capacity exceeded",
12 => "Negotiated TLS parameters not acceptable",
13 => "Use HTTP/1.1 for the request",
_ => "unknown reason",
}
}
Expand Down Expand Up @@ -129,6 +126,9 @@ impl fmt::Debug for Hex {

impl fmt::Display for Reason {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{}", self.description())
match self.0 {
0..=13 => write!(fmt, "{}", self.description()),
_ => write!(fmt, "unknown error code {}", self.0),
}
}
}

0 comments on commit 02f93c9

Please sign in to comment.