Closed
Description
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
tohyper::Body
- Split up the
hyper::Body
type:hyper::body::Empty
: an empty body, yielding no data or trailers. Since it never yields data, itsBuf
type 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.- (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
- Remove
stream
variant - Remove Body's
Once
variant - Make
body::Sender
type andBody::channel()
constructor private. - Rename
Body
toRecv
temporarily - Rename
HttpBody
re-export toBody
- Determine name for
Recv
body type #2971 - Document
hyper::body
module with how to use different body types #3103 - website: Add more in-depth Body guide #3104