-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split apart the Body type #2345
Comments
As a consumer, I like this proposal.
I don't want to jinx this, but it's possible that |
Does this imply that the Client type can drop its body type parameter? That'd be quite nice for reasons even beyond this issue, like allowing non |
I don't see how the client would drop its body type parameter... it still needs to know what kind of bodies you expect to send. |
I like this proposal, I'd also consider adding a |
Would be nice to still be able to use all types at once, as @LucioFranco said. I belive most of apps mix those, eg. |
Something I didn't consider when responding to this initially: what implications, if any, does this proposed change have for h2-style patterns where the initial handshake request has a body of |
If you expect different requests to have different body behaviors, you can use a body type that captures that. |
So, it does seem like this is desirable, but I'm going to punt to the next milestone, since proposing this right when 0.14 was almost ready is kinda late. |
I'm interested in implementing this if it is ok. |
Those body types (maybe except for Having concrete |
I'd like to +1 this. Body things that aren't hyper specific would be nice to have in http-body if thats appropriate. Earlier today I opened a PR for adding |
This adds `StreamBody` which converts a `Stream` of `Bytes` into a `http_body::Body`. --- As suggested by Kestrer on Discord it would make sense for axum to provide different kinds of body types other than `Empty`, `Full`, and `hyper::Body`. There is also some talk about [splitting up `hyper::Body`](hyperium/hyper#2345) so this can be seen as getting started on that effort. axum's body types could be moved to hyper or http-body if thats the direction we decide on. The types I'm thinking about adding are: - `StreamBody`- added in this PR - `AsyncReadBody` - similar to [http-body#41](https://github.com/hyperium/http-body/pull/41/files) - `ChannelBody` - similar to `hyper::Body::channel`
The |
This has been suggested before: the current trait
hyper::body::HttpBody
should be renamed tohyper::Body
, and the existing structhyper::Body
should be split up into more descriptive implementations. I'm coming around to that idea, so here's the full proposal.Proposal
hyper::body::HttpBody
tohyper::Body
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.hyper::body::BoxBody
A 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
stream
variantOnce
variantbody::Sender
type andBody::channel()
constructor private.Body
toRecv
temporarilyHttpBody
re-export toBody
Recv
body type #2971hyper::body
module with how to use different body types #3103The text was updated successfully, but these errors were encountered: