address comments

This commit is contained in:
Rob Ede 2021-05-09 19:18:21 +01:00
parent 8f947e3e14
commit d71d8e0b79
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
4 changed files with 7 additions and 19 deletions

View File

@ -86,16 +86,6 @@ mod tests {
}
}
impl ResponseBody<Body> {
#[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));

View File

@ -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),

View File

@ -92,25 +92,25 @@ impl<B> Response<B> {
}
}
/// 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

View File

@ -236,10 +236,8 @@ impl ResponseBuilder {
/// This `ResponseBuilder` will be left in a useless state.
#[inline]
pub fn body<B: Into<Body>>(&mut self, body: B) -> Response<Body> {
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.