diff --git a/src/frame/reason.rs b/src/frame/reason.rs index ff5e2012..a47c17b9 100644 --- a/src/frame/reason.rs +++ b/src/frame/reason.rs @@ -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", } } @@ -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), + } } } diff --git a/tests/h2-tests/tests/client_request.rs b/tests/h2-tests/tests/client_request.rs index 2af0bdee..6d74c643 100644 --- a/tests/h2-tests/tests/client_request.rs +++ b/tests/h2-tests/tests/client_request.rs @@ -413,7 +413,7 @@ async fn send_reset_notifies_recv_stream() { let err = body.next().await.unwrap().expect_err("RecvBody"); assert_eq!( err.to_string(), - "stream error sent by user: refused stream before processing any application logic" + "stream error sent by user: stream not processed" ); }; @@ -676,7 +676,7 @@ async fn sending_request_on_closed_connection() { }; let poll_err = poll_fn(|cx| client.poll_ready(cx)).await.unwrap_err(); - let msg = "connection error detected: unspecific protocol error detected"; + let msg = "connection error detected: protocol error detected"; assert_eq!(poll_err.to_string(), msg); let request = Request::builder() diff --git a/tests/h2-tests/tests/codec_read.rs b/tests/h2-tests/tests/codec_read.rs index d955e186..e4a90b7f 100644 --- a/tests/h2-tests/tests/codec_read.rs +++ b/tests/h2-tests/tests/codec_read.rs @@ -210,7 +210,7 @@ async fn update_max_frame_len_at_rest() { assert_eq!(codec.max_recv_frame_size(), 16_384); assert_eq!( codec.next().await.unwrap().unwrap_err().to_string(), - "frame with invalid size" + "frame size incorrect" ); // drain codec buffer diff --git a/tests/h2-tests/tests/flow_control.rs b/tests/h2-tests/tests/flow_control.rs index be04a61b..fe8a6be6 100644 --- a/tests/h2-tests/tests/flow_control.rs +++ b/tests/h2-tests/tests/flow_control.rs @@ -217,7 +217,7 @@ async fn recv_data_overflows_connection_window() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: flow-control protocol violated" + "connection error detected: flow-control limits exceeded" ); }; @@ -227,7 +227,7 @@ async fn recv_data_overflows_connection_window() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: flow-control protocol violated" + "connection error detected: flow-control limits exceeded" ); }; join(conn, req).await; @@ -278,7 +278,7 @@ async fn recv_data_overflows_stream_window() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "stream error detected: flow-control protocol violated" + "stream error detected: flow-control limits exceeded" ); }; @@ -358,7 +358,7 @@ async fn stream_error_release_connection_capacity() { .expect_err("body"); assert_eq!( err.to_string(), - "stream error detected: unspecific protocol error detected" + "stream error detected: protocol error detected" ); cap.release_capacity(to_release).expect("release_capacity"); }; diff --git a/tests/h2-tests/tests/push_promise.rs b/tests/h2-tests/tests/push_promise.rs index f52f781d..08570836 100644 --- a/tests/h2-tests/tests/push_promise.rs +++ b/tests/h2-tests/tests/push_promise.rs @@ -164,7 +164,7 @@ async fn recv_push_when_push_disabled_is_conn_error() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: unspecific protocol error detected" + "connection error detected: protocol error detected" ); }; @@ -174,7 +174,7 @@ async fn recv_push_when_push_disabled_is_conn_error() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: unspecific protocol error detected" + "connection error detected: protocol error detected" ); }; @@ -388,7 +388,7 @@ async fn recv_push_promise_skipped_stream_id() { .unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: unspecific protocol error detected" + "connection error detected: protocol error detected" ); }; @@ -398,7 +398,7 @@ async fn recv_push_promise_skipped_stream_id() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: unspecific protocol error detected" + "connection error detected: protocol error detected" ); }; @@ -446,7 +446,7 @@ async fn recv_push_promise_dup_stream_id() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: unspecific protocol error detected" + "connection error detected: protocol error detected" ); }; @@ -456,7 +456,7 @@ async fn recv_push_promise_dup_stream_id() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: unspecific protocol error detected" + "connection error detected: protocol error detected" ); }; diff --git a/tests/h2-tests/tests/stream_states.rs b/tests/h2-tests/tests/stream_states.rs index f2b2efc1..220589f5 100644 --- a/tests/h2-tests/tests/stream_states.rs +++ b/tests/h2-tests/tests/stream_states.rs @@ -209,7 +209,7 @@ async fn errors_if_recv_frame_exceeds_max_frame_size() { let err = res.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: frame with invalid size" + "connection error detected: frame size incorrect" ); }; @@ -218,7 +218,7 @@ async fn errors_if_recv_frame_exceeds_max_frame_size() { let err = h2.await.unwrap_err(); assert_eq!( err.to_string(), - "connection error detected: frame with invalid size" + "connection error detected: frame size incorrect" ); }; join(conn, req).await; @@ -329,7 +329,7 @@ async fn recv_goaway_finishes_processed_streams() { let err = client.get("https://example.com/").await.unwrap_err(); assert_eq!( err.to_string(), - "connection error received: not a result of an error" + "connection error received: graceful shutdown" ); };