diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs index 8a35585e2..c2f1257c1 100644 --- a/src/async_impl/body.rs +++ b/src/async_impl/body.rs @@ -117,17 +117,6 @@ impl Body { } } - /* - #[cfg(feature = "blocking")] - pub(crate) fn wrap(body: hyper::Body) -> Body { - Body { - inner: Inner::Streaming { - body: Box::pin(WrapHyper(body)), - }, - } - } - */ - pub(crate) fn empty() -> Body { Body::reusable(Bytes::new()) } @@ -138,8 +127,20 @@ impl Body { } } - // pub? - pub(crate) fn streaming(inner: B) -> Body + /// Wrap a [`HttpBody`] in a box inside `Body`. + /// + /// # Example + /// + /// ``` + /// # use reqwest::Body; + /// # use futures_util; + /// # fn main() { + /// let content = "hello,world!".to_string(); + /// + /// let body = Body::wrap(content); + /// # } + /// ``` + pub fn wrap(inner: B) -> Body where B: HttpBody + Send + Sync + 'static, B::Data: Into, @@ -483,7 +484,7 @@ mod tests { assert!(!bytes_body.is_end_stream()); assert_eq!(bytes_body.size_hint().exact(), Some(3)); - let stream_body = Body::streaming(bytes_body); + let stream_body = Body::wrap(bytes_body); assert!(!stream_body.is_end_stream()); assert_eq!(stream_body.size_hint().exact(), None); } diff --git a/src/async_impl/response.rs b/src/async_impl/response.rs index 17be37030..23e30d3ed 100644 --- a/src/async_impl/response.rs +++ b/src/async_impl/response.rs @@ -442,7 +442,7 @@ impl fmt::Debug for Response { /// A `Response` can be piped as the `Body` of another request. impl From for Body { fn from(r: Response) -> Body { - Body::streaming(r.res.into_body()) + Body::wrap(r.res.into_body()) } } @@ -477,7 +477,7 @@ impl> From> for Response { impl From for http::Response { fn from(r: Response) -> http::Response { let (parts, body) = r.res.into_parts(); - let body = Body::streaming(body); + let body = Body::wrap(body); http::Response::from_parts(parts, body) } }