From d71d8e0b7931c52fab30598d9f3fc3863d8691d7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 May 2021 19:18:21 +0100 Subject: [PATCH] address comments --- actix-http/src/body/mod.rs | 10 ---------- actix-http/src/h1/dispatcher.rs | 2 +- actix-http/src/response.rs | 8 ++++---- actix-http/src/response_builder.rs | 6 ++---- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/actix-http/src/body/mod.rs b/actix-http/src/body/mod.rs index 89778e1e2..cdfcd226b 100644 --- a/actix-http/src/body/mod.rs +++ b/actix-http/src/body/mod.rs @@ -86,16 +86,6 @@ mod tests { } } - impl ResponseBody { - #[allow(dead_code)] - pub(crate) fn get_ref(&self) -> &[u8] { - match *self { - ResponseBody::Body(ref b) => b.get_ref(), - ResponseBody::Other(ref b) => b.get_ref(), - } - } - } - #[actix_rt::test] async fn test_static_str() { assert_eq!(Body::from("").size(), BodySize::Sized(0)); diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 62e57da14..574f0b2a9 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -473,7 +473,7 @@ where } Poll::Ready(Some(Err(err))) => { - return Err(DispatchError::Service(err.into())) + return Err(DispatchError::Service(err)) } Poll::Pending => return Ok(PollResponse::DoNothing), diff --git a/actix-http/src/response.rs b/actix-http/src/response.rs index 427b2025e..1b3f68505 100644 --- a/actix-http/src/response.rs +++ b/actix-http/src/response.rs @@ -92,25 +92,25 @@ impl Response { } } - /// Return a reference to the head of this response. + /// Returns a reference to the head of this response. #[inline] pub fn head(&self) -> &ResponseHead { &*self.head } - /// Return a mutable reference to the head of this response. + /// Returns a mutable reference to the head of this response. #[inline] pub fn head_mut(&mut self) -> &mut ResponseHead { &mut *self.head } - /// Return the source `error` for this response, if one is set. + /// Returns the source `error` for this response, if one is set. #[inline] pub fn error(&self) -> Option<&Error> { self.error.as_ref() } - /// Return the status code of this response. + /// Returns the status code of this response. #[inline] pub fn status(&self) -> StatusCode { self.head.status diff --git a/actix-http/src/response_builder.rs b/actix-http/src/response_builder.rs index 6c10cacca..3fb94dad5 100644 --- a/actix-http/src/response_builder.rs +++ b/actix-http/src/response_builder.rs @@ -236,10 +236,8 @@ impl ResponseBuilder { /// This `ResponseBuilder` will be left in a useless state. #[inline] pub fn body>(&mut self, body: B) -> Response { - match self.message_body(body.into()) { - Ok(res) => res, - Err(err) => Response::from_error(err), - } + self.message_body(body.into()) + .unwrap_or_else(Response::from_error) } /// Generate response with a body.