From 7c20a0992cf0345380572a004e5111c609f2e056 Mon Sep 17 00:00:00 2001 From: Tiga Ultraman Date: Tue, 12 Nov 2024 10:02:14 +0800 Subject: [PATCH] resolve clippy problem Signed-off-by: Tiga Ultraman --- ylong_http/src/h2/encoder.rs | 4 +-- .../src/async_impl/conn/http2.rs | 36 +++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ylong_http/src/h2/encoder.rs b/ylong_http/src/h2/encoder.rs index adfbef3..f1a802e 100644 --- a/ylong_http/src/h2/encoder.rs +++ b/ylong_http/src/h2/encoder.rs @@ -1767,8 +1767,8 @@ mod ut_frame_encoder { // Validate the encoded GOAWAY frame. let mut expected_encoded_goaway = [0u8; 13]; - expected_encoded_goaway[0..4].copy_from_slice(&(last_stream_id as u32).to_be_bytes()); - expected_encoded_goaway[4..8].copy_from_slice(&(error_code).to_be_bytes()); + expected_encoded_goaway[0..4].copy_from_slice(&last_stream_id.to_be_bytes()); + expected_encoded_goaway[4..8].copy_from_slice(&error_code.to_be_bytes()); expected_encoded_goaway[8..13].copy_from_slice(&debug_data[..]); diff --git a/ylong_http_client/src/async_impl/conn/http2.rs b/ylong_http_client/src/async_impl/conn/http2.rs index 7399e62..eee8370 100644 --- a/ylong_http_client/src/async_impl/conn/http2.rs +++ b/ylong_http_client/src/async_impl/conn/http2.rs @@ -21,7 +21,7 @@ use std::time::Instant; use ylong_http::error::HttpError; use ylong_http::h2; -use ylong_http::h2::{ErrorCode, Frame, FrameFlags, H2Error, Payload, PseudoHeaders}; +use ylong_http::h2::{ErrorCode, Frame, FrameFlags, H2Error, Payload, PseudoHeaders, StreamId}; use ylong_http::headers::Headers; use ylong_http::request::uri::Scheme; use ylong_http::request::RequestPart; @@ -91,12 +91,9 @@ where Some(status) => StatusCode::from_bytes(status.as_bytes()) .map_err(|e| HttpClientError::from_error(ErrorKind::Request, e))?, None => { - return Err(HttpClientError::from_error( - ErrorKind::Request, - HttpError::from(H2Error::StreamError( - headers_frame.stream_id(), - ErrorCode::ProtocolError, - )), + return Err(build_client_error( + headers_frame.stream_id(), + ErrorCode::ProtocolError, )); } }; @@ -107,21 +104,15 @@ where } } Payload::RstStream(reset) => { - return Err(HttpClientError::from_error( - ErrorKind::Request, - HttpError::from(H2Error::StreamError( - headers_frame.stream_id(), - ErrorCode::try_from(reset.error_code()).unwrap_or(ErrorCode::ProtocolError), - )), + return Err(build_client_error( + headers_frame.stream_id(), + ErrorCode::try_from(reset.error_code()).unwrap_or(ErrorCode::ProtocolError), )); } _ => { - return Err(HttpClientError::from_error( - ErrorKind::Request, - HttpError::from(H2Error::StreamError( - headers_frame.stream_id(), - ErrorCode::ProtocolError, - )), + return Err(build_client_error( + headers_frame.stream_id(), + ErrorCode::ProtocolError, )); } }; @@ -208,6 +199,13 @@ fn build_pseudo_headers(request_part: &mut RequestPart) -> Result HttpClientError { + HttpClientError::from_error( + ErrorKind::Request, + HttpError::from(H2Error::StreamError(id, code)), + ) +} + struct TextIo { pub(crate) handle: Http2Conn, pub(crate) offset: usize, -- Gitee