Skip to content
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

Consider implementing HttpBody for Request and Response #2067

Closed
seanmonstar opened this issue Dec 11, 2019 · 3 comments · Fixed by #2077
Closed

Consider implementing HttpBody for Request and Response #2067

seanmonstar opened this issue Dec 11, 2019 · 3 comments · Fixed by #2077
Labels
A-body Area: body streaming. C-feature Category: feature. This is adding a new feature. E-easy Effort: easy. A task that would be a great starting point for a new contributor.

Comments

@seanmonstar
Copy link
Member

In hyperium/http#107, we didn't implement Stream for http::{Request, Response} so as to not have the external dependency. However, in http-body, since we define the trait and import http, we could provide this implementation.

It'd make these slightly nicer:

while let Some(data) = req.data().await {}

let buf = hyper::body::aggregate(req);
@seanmonstar seanmonstar added B-rfc Blocked: More comments would be useful in determine next steps. A-body Area: body streaming. labels Dec 11, 2019
@LucioFranco
Copy link
Member

I think this makes sense but forces http to be async I guess unless we put it behind a feature flag. Otherwise, I think this could be a great addition.

@seanmonstar
Copy link
Member Author

How does it force http to be async? It'd only implement in the http-body crate.

@LucioFranco
Copy link
Member

Ah you're right, if the impl is in the http-body crate then I am +1

@seanmonstar seanmonstar added E-easy Effort: easy. A task that would be a great starting point for a new contributor. C-feature Category: feature. This is adding a new feature. and removed B-rfc Blocked: More comments would be useful in determine next steps. labels Dec 11, 2019
seanmonstar added a commit that referenced this issue Dec 13, 2019
When the body type of a `Request` or `Response` implements `HttpBody`,
the `Request` or `Response` itself now implements `HttpBody`.

This allows writing things like `hyper::body::aggregate(req)` instead of
`hyper::body::aggregate(req.into_body())`.

Closes #2067
seanmonstar added a commit that referenced this issue Dec 13, 2019
When the body type of a `Request` or `Response` implements `HttpBody`,
the `Request` or `Response` itself now implements `HttpBody`.

This allows writing things like `hyper::body::aggregate(req)` instead of
`hyper::body::aggregate(req.into_body())`.

Closes #2067
seanmonstar added a commit that referenced this issue Dec 13, 2019
When the body type of a `Request` or `Response` implements `HttpBody`,
the `Request` or `Response` itself now implements `HttpBody`.

This allows writing things like `hyper::body::aggregate(req)` instead of
`hyper::body::aggregate(req.into_body())`.

Closes #2067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-body Area: body streaming. C-feature Category: feature. This is adding a new feature. E-easy Effort: easy. A task that would be a great starting point for a new contributor.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants