mirror of https://github.com/fafhrd91/actix-web
address comments
This commit is contained in:
parent
8f947e3e14
commit
d71d8e0b79
|
@ -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]
|
#[actix_rt::test]
|
||||||
async fn test_static_str() {
|
async fn test_static_str() {
|
||||||
assert_eq!(Body::from("").size(), BodySize::Sized(0));
|
assert_eq!(Body::from("").size(), BodySize::Sized(0));
|
||||||
|
|
|
@ -473,7 +473,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
Poll::Ready(Some(Err(err))) => {
|
Poll::Ready(Some(Err(err))) => {
|
||||||
return Err(DispatchError::Service(err.into()))
|
return Err(DispatchError::Service(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
Poll::Pending => return Ok(PollResponse::DoNothing),
|
Poll::Pending => return Ok(PollResponse::DoNothing),
|
||||||
|
|
|
@ -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]
|
#[inline]
|
||||||
pub fn head(&self) -> &ResponseHead {
|
pub fn head(&self) -> &ResponseHead {
|
||||||
&*self.head
|
&*self.head
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a mutable reference to the head of this response.
|
/// Returns a mutable reference to the head of this response.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn head_mut(&mut self) -> &mut ResponseHead {
|
pub fn head_mut(&mut self) -> &mut ResponseHead {
|
||||||
&mut *self.head
|
&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]
|
#[inline]
|
||||||
pub fn error(&self) -> Option<&Error> {
|
pub fn error(&self) -> Option<&Error> {
|
||||||
self.error.as_ref()
|
self.error.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the status code of this response.
|
/// Returns the status code of this response.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn status(&self) -> StatusCode {
|
pub fn status(&self) -> StatusCode {
|
||||||
self.head.status
|
self.head.status
|
||||||
|
|
|
@ -236,10 +236,8 @@ impl ResponseBuilder {
|
||||||
/// This `ResponseBuilder` will be left in a useless state.
|
/// This `ResponseBuilder` will be left in a useless state.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn body<B: Into<Body>>(&mut self, body: B) -> Response<Body> {
|
pub fn body<B: Into<Body>>(&mut self, body: B) -> Response<Body> {
|
||||||
match self.message_body(body.into()) {
|
self.message_body(body.into())
|
||||||
Ok(res) => res,
|
.unwrap_or_else(Response::from_error)
|
||||||
Err(err) => Response::from_error(err),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate response with a body.
|
/// Generate response with a body.
|
||||||
|
|
Loading…
Reference in New Issue