diff --git a/examples/client.rs b/examples/client.rs index aa400ea616..126d4395eb 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -4,7 +4,7 @@ use std::env; use bytes::Bytes; use http_body_util::Empty; -use hyper::{body::HttpBody as _, Request}; +use hyper::{body::Body as _, Request}; use tokio::io::{self, AsyncWriteExt as _}; use tokio::net::TcpStream; diff --git a/examples/echo.rs b/examples/echo.rs index c7a564e9e7..b2b601724b 100644 --- a/examples/echo.rs +++ b/examples/echo.rs @@ -4,7 +4,7 @@ use std::net::SocketAddr; use bytes::Bytes; use http_body_util::{combinators::BoxBody, BodyExt, Empty, Full}; -use hyper::body::HttpBody as _; +use hyper::body::Body as _; use hyper::server::conn::Http; use hyper::service::service_fn; use hyper::{Method, Recv, Request, Response, StatusCode}; diff --git a/examples/single_threaded.rs b/examples/single_threaded.rs index 788bbcebf0..14989c91a2 100644 --- a/examples/single_threaded.rs +++ b/examples/single_threaded.rs @@ -6,7 +6,7 @@ use std::net::SocketAddr; use std::rc::Rc; use tokio::net::TcpListener; -use hyper::body::{Bytes, HttpBody}; +use hyper::body::{Body as HttpBody, Bytes}; use hyper::header::{HeaderMap, HeaderValue}; use hyper::service::service_fn; use hyper::{Error, Response}; diff --git a/src/body/aggregate.rs b/src/body/aggregate.rs index 99662419d3..8a27b36051 100644 --- a/src/body/aggregate.rs +++ b/src/body/aggregate.rs @@ -1,11 +1,11 @@ use bytes::Buf; -use super::HttpBody; +use super::Body; use crate::common::buf::BufList; /// Aggregate the data buffers from a body asynchronously. /// -/// The returned `impl Buf` groups the `Buf`s from the `HttpBody` without +/// The returned `impl Buf` groups the `Buf`s from the `Body` without /// copying them. This is ideal if you don't require a contiguous buffer. /// /// # Note @@ -15,7 +15,7 @@ use crate::common::buf::BufList; /// `Content-Length` is a possibility, but it is not strictly mandated to be present. pub async fn aggregate(body: T) -> Result where - T: HttpBody, + T: Body, { let mut bufs = BufList::new(); diff --git a/src/body/body.rs b/src/body/body.rs index 6cae4916da..616e617492 100644 --- a/src/body/body.rs +++ b/src/body/body.rs @@ -5,7 +5,7 @@ use futures_channel::mpsc; use futures_channel::oneshot; use futures_core::Stream; // for mpsc::Receiver use http::HeaderMap; -use http_body::{Body as HttpBody, SizeHint}; +use http_body::{Body, SizeHint}; use super::DecodedLength; use crate::common::Future; @@ -18,7 +18,7 @@ type TrailersSender = oneshot::Sender; /// A stream of `Bytes`, used when receiving bodies. /// -/// A good default [`HttpBody`](crate::body::HttpBody) to use in many +/// A good default [`Body`](crate::body::Body) to use in many /// applications. /// /// Note: To read the full body, use [`body::to_bytes`](crate::body::to_bytes) @@ -195,7 +195,7 @@ impl Recv { } } -impl HttpBody for Recv { +impl Body for Recv { type Data = Bytes; type Error = crate::Error; @@ -386,7 +386,7 @@ mod tests { use std::mem; use std::task::Poll; - use super::{DecodedLength, HttpBody, Recv, Sender, SizeHint}; + use super::{Body, DecodedLength, Recv, Sender, SizeHint}; #[test] fn test_size_of() { @@ -402,7 +402,7 @@ mod tests { body_expected_size, ); - assert_eq!(body_size, mem::size_of::>(), "Option"); + assert_eq!(body_size, mem::size_of::>(), "Option"); assert_eq!( mem::size_of::(), diff --git a/src/body/mod.rs b/src/body/mod.rs index 369e6f5145..30ee91ad7e 100644 --- a/src/body/mod.rs +++ b/src/body/mod.rs @@ -7,16 +7,16 @@ //! //! There are two pieces to this in hyper: //! -//! - **The [`HttpBody`](HttpBody) trait** describes all possible bodies. -//! hyper allows any body type that implements `HttpBody`, allowing +//! - **The [`Body`](Body) trait** describes all possible bodies. +//! hyper allows any body type that implements `Body`, allowing //! applications to have fine-grained control over their streaming. //! - **The [`Recv`](Recv) concrete type**, which is an implementation of -//! `HttpBody`, and returned by hyper as a "receive stream" (so, for server +//! `Body`, and returned by hyper as a "receive stream" (so, for server //! requests and client responses). It is also a decent default implementation //! if you don't have very custom needs of your send streams. pub use bytes::{Buf, Bytes}; -pub use http_body::Body as HttpBody; +pub use http_body::Body; pub use http_body::SizeHint; pub use self::aggregate::aggregate; diff --git a/src/body/to_bytes.rs b/src/body/to_bytes.rs index cfb6f1f56c..19d23412ce 100644 --- a/src/body/to_bytes.rs +++ b/src/body/to_bytes.rs @@ -1,6 +1,6 @@ use bytes::{Buf, BufMut, Bytes}; -use super::HttpBody; +use super::Body; /// Concatenate the buffers from a body into a single `Bytes` asynchronously. /// @@ -19,7 +19,7 @@ use super::HttpBody; /// ``` /// # use hyper::{Recv, Response}; /// # async fn doc(response: Response) -> hyper::Result<()> { -/// # use hyper::body::HttpBody; +/// # use hyper::body::Body; /// // let response: Response ... /// /// const MAX_ALLOWED_RESPONSE_SIZE: u64 = 1024; @@ -39,7 +39,7 @@ use super::HttpBody; /// ``` pub async fn to_bytes(body: T) -> Result where - T: HttpBody, + T: Body, { futures_util::pin_mut!(body); diff --git a/src/client/conn/http1.rs b/src/client/conn/http1.rs index 7b8372de69..e50567ce6b 100644 --- a/src/client/conn/http1.rs +++ b/src/client/conn/http1.rs @@ -9,7 +9,7 @@ use httparse::ParserConfig; use tokio::io::{AsyncRead, AsyncWrite}; use crate::Recv; -use crate::body::HttpBody; +use crate::body::Body; use crate::common::{ exec::{BoxSendFuture, Exec}, task, Future, Pin, Poll, @@ -35,7 +35,7 @@ pub struct SendRequest { pub struct Connection where T: AsyncRead + AsyncWrite + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, { inner: Option>, } @@ -102,7 +102,7 @@ impl SendRequest { impl SendRequest where - B: HttpBody + 'static, + B: Body + 'static, { /// Sends a `Request` on the associated connection. /// @@ -180,7 +180,7 @@ impl fmt::Debug for SendRequest { impl fmt::Debug for Connection where T: AsyncRead + AsyncWrite + fmt::Debug + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Connection").finish() @@ -190,7 +190,7 @@ where impl Future for Connection where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + Send + 'static, + B: Body + Send + 'static, B::Data: Send, B::Error: Into>, { @@ -427,7 +427,7 @@ impl Builder { ) -> impl Future, Connection)>> where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Data: Send, B::Error: Into>, { diff --git a/src/client/conn/http2.rs b/src/client/conn/http2.rs index d0a3e58a0b..50bcb20afd 100644 --- a/src/client/conn/http2.rs +++ b/src/client/conn/http2.rs @@ -11,7 +11,7 @@ use http::{Request, Response}; use tokio::io::{AsyncRead, AsyncWrite}; use crate::Recv; -use crate::body::HttpBody; +use crate::body::Body; use crate::common::{ exec::{BoxSendFuture, Exec}, task, Future, Pin, Poll, @@ -33,7 +33,7 @@ pub struct SendRequest { pub struct Connection where T: AsyncRead + AsyncWrite + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, { inner: (PhantomData, proto::h2::ClientTask), } @@ -96,7 +96,7 @@ impl SendRequest { impl SendRequest where - B: HttpBody + 'static, + B: Body + 'static, { /// Sends a `Request` on the associated connection. /// @@ -174,7 +174,7 @@ impl fmt::Debug for SendRequest { impl fmt::Debug for Connection where T: AsyncRead + AsyncWrite + fmt::Debug + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Connection").finish() @@ -184,7 +184,7 @@ where impl Future for Connection where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + Send + 'static, + B: Body + Send + 'static, B::Data: Send, B::Error: Into>, { @@ -388,7 +388,7 @@ impl Builder { ) -> impl Future, Connection)>> where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Data: Send, B::Error: Into>, { diff --git a/src/client/conn/mod.rs b/src/client/conn/mod.rs index ad83f4e89e..159a24369d 100644 --- a/src/client/conn/mod.rs +++ b/src/client/conn/mod.rs @@ -73,7 +73,7 @@ use tower_service::Service; use tracing::{debug, trace}; use super::dispatch; -use crate::body::HttpBody; +use crate::body::Body; #[cfg(not(all(feature = "http1", feature = "http2")))] use crate::common::Never; use crate::common::{ @@ -108,7 +108,7 @@ pin_project! { #[project = ProtoClientProj] enum ProtoClient where - B: HttpBody, + B: Body, { H1 { #[pin] @@ -130,7 +130,7 @@ pub async fn handshake( ) -> crate::Result<(SendRequest, Connection)> where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Data: Send, B::Error: Into>, { @@ -150,7 +150,7 @@ pub struct SendRequest { pub struct Connection where T: AsyncRead + AsyncWrite + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, { inner: Option>, } @@ -232,7 +232,7 @@ impl SendRequest { impl SendRequest where - B: HttpBody + 'static, + B: Body + 'static, { /// Sends a `Request` on the associated connection. /// @@ -266,7 +266,7 @@ where impl Service> for SendRequest where - B: HttpBody + 'static, + B: Body + 'static, { type Response = Response; type Error = crate::Error; @@ -292,7 +292,7 @@ impl fmt::Debug for SendRequest { impl Connection where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + Unpin + Send + 'static, + B: Body + Unpin + Send + 'static, B::Data: Send, B::Error: Into>, { @@ -375,7 +375,7 @@ where impl Future for Connection where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + Send + 'static, + B: Body + Send + 'static, B::Data: Send, B::Error: Into>, { @@ -403,7 +403,7 @@ where impl fmt::Debug for Connection where T: AsyncRead + AsyncWrite + fmt::Debug + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Connection").finish() @@ -806,7 +806,7 @@ impl Builder { ) -> impl Future, Connection)>> where T: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Data: Send, B::Error: Into>, { @@ -905,7 +905,7 @@ impl fmt::Debug for ResponseFuture { impl Future for ProtoClient where T: AsyncRead + AsyncWrite + Send + Unpin + 'static, - B: HttpBody + Send + 'static, + B: Body + Send + 'static, B::Data: Send, B::Error: Into>, { @@ -938,7 +938,7 @@ impl AssertSendSync for SendRequest {} impl AssertSend for Connection where T: AsyncRead + AsyncWrite + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Data: Send, { } @@ -947,7 +947,7 @@ where impl AssertSendSync for Connection where T: AsyncRead + AsyncWrite + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Data: Send + Sync + 'static, { } diff --git a/src/common/exec.rs b/src/common/exec.rs index 1cc7036001..decd6138d6 100644 --- a/src/common/exec.rs +++ b/src/common/exec.rs @@ -4,13 +4,13 @@ use std::pin::Pin; use std::sync::Arc; #[cfg(feature = "server")] -use crate::body::HttpBody; +use crate::body::Body; #[cfg(all(feature = "http2", feature = "server"))] use crate::proto::h2::server::H2Stream; use crate::rt::Executor; #[cfg(feature = "server")] -pub trait ConnStreamExec: Clone { +pub trait ConnStreamExec: Clone { fn execute_h2stream(&mut self, fut: H2Stream); } @@ -60,7 +60,7 @@ impl fmt::Debug for Exec { impl ConnStreamExec for Exec where H2Stream: Future + Send + 'static, - B: HttpBody, + B: Body, { fn execute_h2stream(&mut self, fut: H2Stream) { self.execute(fut) @@ -74,7 +74,7 @@ impl ConnStreamExec for E where E: Executor> + Clone, H2Stream: Future, - B: HttpBody, + B: Body, { fn execute_h2stream(&mut self, fut: H2Stream) { self.execute(fut) @@ -94,7 +94,7 @@ pub struct H2Stream(std::marker::PhantomData<(F, B)>); impl Future for H2Stream where F: Future, E>>, - B: crate::body::HttpBody, + B: crate::body::Body, B::Error: Into>, E: Into>, { diff --git a/src/error.rs b/src/error.rs index e949ea4ae9..e7eec11c3a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -84,7 +84,7 @@ pub(super) enum Header { #[derive(Debug)] pub(super) enum User { - /// Error calling user's HttpBody::poll_data(). + /// Error calling user's Body::poll_data(). #[cfg(any(feature = "http1", feature = "http2"))] Body, /// The user aborted writing of the outgoing body. @@ -384,7 +384,7 @@ impl Error { Kind::Io => "connection error", #[cfg(any(feature = "http1", feature = "http2"))] - Kind::User(User::Body) => "error from user's HttpBody stream", + Kind::User(User::Body) => "error from user's Body stream", Kind::User(User::BodyWriteAborted) => "user body write aborted", #[cfg(any(feature = "http1", feature = "http2"))] Kind::User(User::Service) => "error from user's Service", diff --git a/src/ffi/body.rs b/src/ffi/body.rs index ae2c62eebe..b6f90879f3 100644 --- a/src/ffi/body.rs +++ b/src/ffi/body.rs @@ -8,7 +8,7 @@ use libc::{c_int, size_t}; use super::task::{hyper_context, hyper_task, hyper_task_return_type, AsTaskType}; use super::{UserDataPointer, HYPER_ITER_CONTINUE}; -use crate::body::{Bytes, HttpBody as _, Recv}; +use crate::body::{Body as _, Bytes, Recv}; /// A streaming HTTP body. pub struct hyper_body(pub(super) Recv); diff --git a/src/proto/h1/dispatch.rs b/src/proto/h1/dispatch.rs index c744db8648..38061421cf 100644 --- a/src/proto/h1/dispatch.rs +++ b/src/proto/h1/dispatch.rs @@ -6,12 +6,12 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tracing::{debug, trace}; use super::{Http1Transaction, Wants}; -use crate::body::{Recv, DecodedLength, HttpBody}; +use crate::body::{Recv, DecodedLength, Body}; use crate::common::{task, Future, Pin, Poll, Unpin}; use crate::proto::{BodyLength, Conn, Dispatched, MessageHead, RequestHead}; use crate::upgrade::OnUpgrade; -pub(crate) struct Dispatcher { +pub(crate) struct Dispatcher { conn: Conn, dispatch: D, body_tx: Option, @@ -65,7 +65,7 @@ where D::PollError: Into>, I: AsyncRead + AsyncWrite + Unpin, T: Http1Transaction + Unpin, - Bs: HttpBody + 'static, + Bs: Body + 'static, Bs::Error: Into>, { pub(crate) fn new(dispatch: D, conn: Conn) -> Self { @@ -403,7 +403,7 @@ where D::PollError: Into>, I: AsyncRead + AsyncWrite + Unpin, T: Http1Transaction + Unpin, - Bs: HttpBody + 'static, + Bs: Body + 'static, Bs::Error: Into>, { type Output = crate::Result; @@ -464,7 +464,7 @@ cfg_server! { where S: HttpService, S::Error: Into>, - Bs: HttpBody, + Bs: Body, { type PollItem = MessageHead; type PollBody = Bs; @@ -540,7 +540,7 @@ cfg_client! { impl Dispatch for Client where - B: HttpBody, + B: Body, { type PollItem = RequestHead; type PollBody = B; diff --git a/src/proto/h1/role.rs b/src/proto/h1/role.rs index dd8b6b5e86..408df4effb 100644 --- a/src/proto/h1/role.rs +++ b/src/proto/h1/role.rs @@ -673,7 +673,7 @@ impl Server { } match msg.body { Some(BodyLength::Known(known_len)) => { - // The HttpBody claims to know a length, and + // The Body claims to know a length, and // the headers are already set. For performance // reasons, we are just going to trust that // the values match. @@ -706,7 +706,7 @@ impl Server { continue 'headers; } Some(BodyLength::Unknown) => { - // The HttpBody impl didn't know how long the + // The Body impl didn't know how long the // body is, but a length header was included. // We have to parse the value to return our // Encoder... @@ -1243,7 +1243,7 @@ impl Client { let headers = &mut head.headers; // If the user already set specific headers, we should respect them, regardless - // of what the HttpBody knows about itself. They set them for a reason. + // of what the Body knows about itself. They set them for a reason. // Because of the borrow checker, we can't check the for an existing // Content-Length header while holding an `Entry` for the Transfer-Encoding diff --git a/src/proto/h2/client.rs b/src/proto/h2/client.rs index 9933a84a05..e2252955c4 100644 --- a/src/proto/h2/client.rs +++ b/src/proto/h2/client.rs @@ -12,7 +12,7 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tracing::{debug, trace, warn}; use super::{ping, H2Upgraded, PipeToSendStream, SendBuf}; -use crate::body::HttpBody; +use crate::body::Body; use crate::common::{exec::Exec, task, Future, Never, Pin, Poll}; use crate::ext::Protocol; use crate::headers; @@ -112,7 +112,7 @@ pub(crate) async fn handshake( ) -> crate::Result> where T: AsyncRead + AsyncWrite + Send + Unpin + 'static, - B: HttpBody, + B: Body, B::Data: Send + 'static, { let (h2_tx, mut conn) = new_builder(config) @@ -195,7 +195,7 @@ where pub(crate) struct ClientTask where - B: HttpBody, + B: Body, { ping: ping::Recorder, conn_drop_ref: ConnDropRef, @@ -207,7 +207,7 @@ where impl ClientTask where - B: HttpBody + 'static, + B: Body + 'static, { pub(crate) fn is_extended_connect_protocol_enabled(&self) -> bool { self.h2_tx.is_extended_connect_protocol_enabled() @@ -216,7 +216,7 @@ where impl Future for ClientTask where - B: HttpBody + Send + 'static, + B: Body + Send + 'static, B::Data: Send, B::Error: Into>, { diff --git a/src/proto/h2/mod.rs b/src/proto/h2/mod.rs index 5857c919d1..288a444bb2 100644 --- a/src/proto/h2/mod.rs +++ b/src/proto/h2/mod.rs @@ -10,7 +10,7 @@ use std::task::Context; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tracing::{debug, trace, warn}; -use crate::body::HttpBody; +use crate::body::Body; use crate::common::{task, Future, Pin, Poll}; use crate::proto::h2::ping::Recorder; @@ -87,7 +87,7 @@ fn strip_connection_headers(headers: &mut HeaderMap, is_request: bool) { pin_project! { struct PipeToSendStream where - S: HttpBody, + S: Body, { body_tx: SendStream>, data_done: bool, @@ -98,7 +98,7 @@ pin_project! { impl PipeToSendStream where - S: HttpBody, + S: Body, { fn new(stream: S, tx: SendStream>) -> PipeToSendStream { PipeToSendStream { @@ -111,7 +111,7 @@ where impl Future for PipeToSendStream where - S: HttpBody, + S: Body, S::Error: Into>, { type Output = crate::Result<()>; diff --git a/src/proto/h2/server.rs b/src/proto/h2/server.rs index 47c6912746..20867e62ba 100644 --- a/src/proto/h2/server.rs +++ b/src/proto/h2/server.rs @@ -12,7 +12,7 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tracing::{debug, trace, warn}; use super::{ping, PipeToSendStream, SendBuf}; -use crate::body::HttpBody; +use crate::body::Body; use crate::common::exec::ConnStreamExec; use crate::common::{date, task, Future, Pin, Poll}; use crate::ext::Protocol; @@ -77,7 +77,7 @@ pin_project! { pub(crate) struct Server where S: HttpService, - B: HttpBody, + B: Body, { exec: E, service: S, @@ -87,7 +87,7 @@ pin_project! { enum State where - B: HttpBody, + B: Body, { Handshaking { ping_config: ping::Config, @@ -99,7 +99,7 @@ where struct Serving where - B: HttpBody, + B: Body, { ping: Option<(ping::Recorder, ping::Ponger)>, conn: Connection>, @@ -111,7 +111,7 @@ where T: AsyncRead + AsyncWrite + Unpin, S: HttpService, S::Error: Into>, - B: HttpBody + 'static, + B: Body + 'static, E: ConnStreamExec, { pub(crate) fn new(io: T, service: S, config: &Config, exec: E) -> Server { @@ -183,7 +183,7 @@ where T: AsyncRead + AsyncWrite + Unpin, S: HttpService, S::Error: Into>, - B: HttpBody + 'static, + B: Body + 'static, E: ConnStreamExec, { type Output = crate::Result; @@ -227,7 +227,7 @@ where impl Serving where T: AsyncRead + AsyncWrite + Unpin, - B: HttpBody + 'static, + B: Body + 'static, { fn poll_server( &mut self, @@ -373,7 +373,7 @@ pin_project! { #[allow(missing_debug_implementations)] pub struct H2Stream where - B: HttpBody, + B: Body, { reply: SendResponse>, #[pin] @@ -385,7 +385,7 @@ pin_project! { #[project = H2StreamStateProj] enum H2StreamState where - B: HttpBody, + B: Body, { Service { #[pin] @@ -407,7 +407,7 @@ struct ConnectParts { impl H2Stream where - B: HttpBody, + B: Body, { fn new( fut: F, @@ -437,7 +437,7 @@ macro_rules! reply { impl H2Stream where F: Future, E>>, - B: HttpBody, + B: Body, B::Data: 'static, B::Error: Into>, E: Into>, @@ -530,7 +530,7 @@ where impl Future for H2Stream where F: Future, E>>, - B: HttpBody, + B: Body, B::Data: 'static, B::Error: Into>, E: Into>, diff --git a/src/server/conn.rs b/src/server/conn.rs index ceb7b61a5f..2ab4ce336c 100644 --- a/src/server/conn.rs +++ b/src/server/conn.rs @@ -67,7 +67,7 @@ cfg_feature! { use tokio::io::{AsyncRead, AsyncWrite}; use tracing::trace; - use crate::body::{Recv, HttpBody}; + use crate::body::{Recv, Body}; use crate::common::{task, Future, Pin, Poll, Unpin}; #[cfg(not(all(feature = "http1", feature = "http2")))] use crate::common::Never; @@ -153,7 +153,7 @@ pin_project! { pub(super) enum ProtoServer where S: HttpService, - B: HttpBody, + B: Body, { H1 { #[pin] @@ -601,7 +601,7 @@ impl Http { where S: HttpService, S::Error: Into>, - Bd: HttpBody + 'static, + Bd: Body + 'static, Bd::Error: Into>, I: AsyncRead + AsyncWrite + Unpin, E: ConnStreamExec, @@ -682,7 +682,7 @@ where S: HttpService, S::Error: Into>, I: AsyncRead + AsyncWrite + Unpin, - B: HttpBody + 'static, + B: Body + 'static, B::Error: Into>, E: ConnStreamExec, { @@ -852,7 +852,7 @@ where S: HttpService, S::Error: Into>, I: AsyncRead + AsyncWrite + Unpin + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Error: Into>, E: ConnStreamExec, { @@ -931,7 +931,7 @@ where T: AsyncRead + AsyncWrite + Unpin, S: HttpService, S::Error: Into>, - B: HttpBody + 'static, + B: Body + 'static, B::Error: Into>, E: ConnStreamExec, { @@ -974,7 +974,7 @@ mod upgrades { S: HttpService, S::Error: Into>, I: AsyncRead + AsyncWrite + Unpin, - B: HttpBody + 'static, + B: Body + 'static, B::Error: Into>, E: ConnStreamExec, { @@ -992,7 +992,7 @@ mod upgrades { S: HttpService, S::Error: Into>, I: AsyncRead + AsyncWrite + Unpin + Send + 'static, - B: HttpBody + 'static, + B: Body + 'static, B::Error: Into>, E: ConnStreamExec, { diff --git a/src/service/http.rs b/src/service/http.rs index 81a20c80b5..ff05586498 100644 --- a/src/service/http.rs +++ b/src/service/http.rs @@ -1,13 +1,13 @@ use std::error::Error as StdError; -use crate::body::HttpBody; +use crate::body::Body; use crate::common::{task, Future, Poll}; use crate::{Request, Response}; /// An asynchronous function from `Request` to `Response`. pub trait HttpService: sealed::Sealed { - /// The `HttpBody` body of the `http::Response`. - type ResBody: HttpBody; + /// The `Body` body of the `http::Response`. + type ResBody: Body; /// The error type that can occur within this `Service`. /// @@ -29,7 +29,7 @@ pub trait HttpService: sealed::Sealed { impl HttpService for T where T: tower_service::Service, Response = Response>, - B2: HttpBody, + B2: Body, T::Error: Into>, { type ResBody = B2; @@ -49,7 +49,7 @@ where impl sealed::Sealed for T where T: tower_service::Service, Response = Response>, - B2: HttpBody, + B2: Body, { } diff --git a/src/service/util.rs b/src/service/util.rs index 363133e3d4..f6dda7711f 100644 --- a/src/service/util.rs +++ b/src/service/util.rs @@ -2,7 +2,7 @@ use std::error::Error as StdError; use std::fmt; use std::marker::PhantomData; -use crate::body::HttpBody; +use crate::body::Body; use crate::common::{task, Future, Poll}; use crate::{Request, Response}; @@ -47,10 +47,10 @@ impl tower_service::Service for ServiceFn where F: FnMut(Request) -> Ret, - ReqBody: HttpBody, + ReqBody: Body, Ret: Future, E>>, E: Into>, - ResBody: HttpBody, + ResBody: Body, { type Response = crate::Response; type Error = E; diff --git a/tests/client.rs b/tests/client.rs index 2f8e352517..4016361b4d 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -1340,7 +1340,7 @@ mod conn { use tokio::io::{AsyncRead, AsyncReadExt as _, AsyncWrite, AsyncWriteExt as _, ReadBuf}; use tokio::net::{TcpListener as TkTcpListener, TcpStream}; - use hyper::body::HttpBody; + use hyper::body::Body; use hyper::client::conn; use hyper::upgrade::OnUpgrade; use hyper::{self, Method, Recv, Request, Response, StatusCode}; @@ -1449,7 +1449,7 @@ mod conn { #[test] fn incoming_content_length() { - use hyper::body::HttpBody; + use hyper::body::Body; let server = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = server.local_addr().unwrap(); diff --git a/tests/server.rs b/tests/server.rs index c520d21775..04b82b67f9 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -25,7 +25,7 @@ use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener as TkTcpListener, TcpListener, TcpStream as TkTcpStream}; -use hyper::body::HttpBody; +use hyper::body::Body; use hyper::server::conn::Http; use hyper::service::service_fn; use hyper::{Method, Recv, Request, Response, StatusCode, Uri, Version}; @@ -260,7 +260,7 @@ mod response_body_lengths { fn auto_response_with_unknown_length() { run_test(TestCase { version: 1, - // no headers means trying to guess from HttpBody + // no headers means trying to guess from Body headers: &[], body: Bd::Unknown("foo bar baz"), expects_chunked: true, @@ -272,7 +272,7 @@ mod response_body_lengths { fn auto_response_with_known_length() { run_test(TestCase { version: 1, - // no headers means trying to guess from HttpBody + // no headers means trying to guess from Body headers: &[], body: Bd::Known("foo bar baz"), expects_chunked: false, @@ -284,7 +284,7 @@ mod response_body_lengths { fn auto_response_known_empty() { run_test(TestCase { version: 1, - // no headers means trying to guess from HttpBody + // no headers means trying to guess from Body headers: &[], body: Bd::Known(""), expects_chunked: false, @@ -296,7 +296,7 @@ mod response_body_lengths { fn http10_auto_response_with_unknown_length() { run_test(TestCase { version: 0, - // no headers means trying to guess from HttpBody + // no headers means trying to guess from Body headers: &[], body: Bd::Unknown("foo bar baz"), expects_chunked: false,