This has been suggested before: the current trait hyper::body::HttpBody should be renamed to hyper::Body, and the existing struct hyper::Body should be split up into more descriptive implementations. I'm coming around to that idea, so here's the full proposal.
Proposal
- Change the trait
hyper::body::HttpBody to hyper::Body
- Split up the
hyper::Body type:
hyper::body::Empty: an empty body, yielding no data or trailers. Since it never yields data, its Buf type could even be some enum NeverBuf {}.
hyper::body::Full: the full body, able to yield 1 data buffer (what hyper::Body::from(buf) is in 0.13).
hyper::body::Streaming: the streaming bodies received from a remote over HTTP/1 or 2.
- (Optional)
hyper::body::BoxBody
A client response would then be Response<Streaming> (as would a server Request<Streaming>), since they are streamed from the connection. Hopefully, this should make the intent clearer when you have a Request<Empty> or Response<Full>, instead of just Request<Body>.
Status: Accepted
Progress
This has been suggested before: the current trait
hyper::body::HttpBodyshould be renamed tohyper::Body, and the existing structhyper::Bodyshould be split up into more descriptive implementations. I'm coming around to that idea, so here's the full proposal.Proposal
hyper::body::HttpBodytohyper::Bodyhyper::Bodytype:hyper::body::Empty: an empty body, yielding no data or trailers. Since it never yields data, itsBuftype could even be someenum NeverBuf {}.hyper::body::Full: the full body, able to yield 1 data buffer (whathyper::Body::from(buf)is in 0.13).hyper::body::Streaming: the streaming bodies received from a remote over HTTP/1 or 2.hyper::body::BoxBodyA client response would then be
Response<Streaming>(as would a serverRequest<Streaming>), since they are streamed from the connection. Hopefully, this should make the intent clearer when you have aRequest<Empty>orResponse<Full>, instead of justRequest<Body>.Status: Accepted
Progress
streamvariantOncevariantbody::Sendertype andBody::channel()constructor private.BodytoRecvtemporarilyHttpBodyre-export toBodyRecvbody type #2971hyper::bodymodule with how to use different body types #3103