-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Create a http::Response<hyper::Body>
from a reqwest::Response
#1954
Conversation
impl From<Response> for http::Response<hyper::Body> { | ||
fn from(r: Response) -> http::Response<hyper::Body> { | ||
let (parts, body) = r.res.into_parts(); | ||
http::Response::from_parts(parts, hyper::Body::wrap_stream(body)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we could give the body without wrapping it prematurely, and then anyone needing to unify it could wrap it themselves. If they didn't need to, we could save them a boxed trait object.
Is there any reason we shouldn't do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good I just don't know how as the body returned by into_parts
has the private Decoder
type so we need to wrap it some way right? If this were a method I suppose we could return http::Response<impl Stream<..>>
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In at least the blocking implementation, I'd like to use a similar conversion trait for a simple Vec<u8>
. See how ureq
provides a few of them:
Seems there's also #1258, #1483, #1612 to track and implement (something) like this. The latter being a PR implementing the same trait in src/async_impl/response.rs
but for anything with a From<Decoder>
. @seanmonstar is one of these PRs "superseding" the other? Can I help gain some traction on any of these?
cc @seanmonstar Can you address my question? |
4497989
to
687fdfc
Compare
I realized this PR exists after I posted #2060, which solves the same issue but with a slightly larger scope. I personally think it's better to make reqwest types |
687fdfc
to
8bdbc64
Compare
Yeah that is true especially with hyper 1.0 - getting rid of its own body type now. |
As discussed in #1951 here is the conversion trait implementation.