Skip to content

Commit 02f93c9

Browse files
committed
Use iana H2 error code description
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.
1 parent ce81583 commit 02f93c9

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/frame/reason.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,20 @@ impl Reason {
6262
/// Get a string description of the error code.
6363
pub fn description(&self) -> &str {
6464
match self.0 {
65-
0 => "not a result of an error",
66-
1 => "unspecific protocol error detected",
67-
2 => "unexpected internal error encountered",
68-
3 => "flow-control protocol violated",
69-
4 => "settings ACK not received in timely manner",
70-
5 => "received frame when stream half-closed",
71-
6 => "frame with invalid size",
72-
7 => "refused stream before processing any application logic",
73-
8 => "stream no longer needed",
74-
9 => "unable to maintain the header compression context",
75-
10 => {
76-
"connection established in response to a CONNECT request was reset or abnormally \
77-
closed"
78-
}
79-
11 => "detected excessive load generating behavior",
80-
12 => "security properties do not meet minimum requirements",
81-
13 => "endpoint requires HTTP/1.1",
65+
0 => "Graceful shutdown",
66+
1 => "Protocol error detected",
67+
2 => "Implementation fault",
68+
3 => "Flow-control limits exceeded",
69+
4 => "Settings not acknowledged",
70+
5 => "Frame received for closed stream",
71+
6 => "Frame size incorrect",
72+
7 => "Stream not processed",
73+
8 => "Stream cancelled",
74+
9 => "Compression state not updated",
75+
10 => "TCP connection error for CONNECT method",
76+
11 => "Processing capacity exceeded",
77+
12 => "Negotiated TLS parameters not acceptable",
78+
13 => "Use HTTP/1.1 for the request",
8279
_ => "unknown reason",
8380
}
8481
}
@@ -129,6 +126,9 @@ impl fmt::Debug for Hex {
129126

130127
impl fmt::Display for Reason {
131128
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
132-
write!(fmt, "{}", self.description())
129+
match self.0 {
130+
0..=13 => write!(fmt, "{}", self.description()),
131+
_ => write!(fmt, "unknown error code {}", self.0),
132+
}
133133
}
134134
}

0 commit comments

Comments
 (0)