diff --git a/examples/client_json.rs b/examples/client_json.rs
index addd7ab57b..3c03bb4882 100644
--- a/examples/client_json.rs
+++ b/examples/client_json.rs
@@ -1,6 +1,7 @@
#![deny(warnings)]
#![warn(rust_2018_idioms)]
+
use hyper::Body;
use hyper::{body::Buf, Request};
use serde::Deserialize;
diff --git a/examples/echo.rs b/examples/echo.rs
index 097851795d..fc3c82d451 100644
--- a/examples/echo.rs
+++ b/examples/echo.rs
@@ -46,7 +46,7 @@ async fn echo(req: Request
) -> Result, hyper::Error> {
// Return the 404 Not Found for other routes.
_ => {
- let mut not_found = Response::default();
+ let mut not_found = Response::new(());
*not_found.status_mut() = StatusCode::NOT_FOUND;
Ok(not_found)
}
diff --git a/src/body/body.rs b/src/body/body.rs
index 856aea3e29..f06b745980 100644
--- a/src/body/body.rs
+++ b/src/body/body.rs
@@ -1,4 +1,3 @@
-use std::borrow::Cow;
use std::fmt;
use bytes::Bytes;
@@ -35,7 +34,8 @@ pub struct Body {
}
enum Kind {
- Once(Option),
+ #[allow(dead_code)]
+ Empty,
Chan {
content_length: DecodedLength,
want_tx: watch::Sender,
@@ -104,21 +104,6 @@ const WANT_PENDING: usize = 1;
const WANT_READY: usize = 2;
impl Body {
- /// Create an empty `Body` stream.
- ///
- /// # Example
- ///
- /// ```
- /// use hyper::{Body, Request};
- ///
- /// // create a `GET /` request
- /// let get = Request::new(Body::empty());
- /// ```
- #[inline]
- pub fn empty() -> Body {
- Body::new(Kind::Once(None))
- }
-
/// Create a `Body` stream with an associated sender half.
///
/// Useful when wanting to stream chunks from another thread.
@@ -176,6 +161,18 @@ impl Body {
body
}
+ #[cfg(feature = "ffi")]
+ #[inline]
+ pub(crate) fn ffi() -> Self {
+ Body::new(Kind::Ffi(crate::ffi::UserBody::new()))
+ }
+
+ #[allow(dead_code)]
+ #[inline]
+ pub(crate) fn empty() -> Self {
+ Body::new(Kind::Empty)
+ }
+
#[cfg(any(feature = "http1", feature = "http2"))]
#[cfg(feature = "client")]
pub(crate) fn delayed_eof(&mut self, fut: DelayEofUntil) {
@@ -249,7 +246,7 @@ impl Body {
fn poll_inner(&mut self, cx: &mut task::Context<'_>) -> Poll