reqwest
reqwest copied to clipboard
Cannot construct `blocking::Response` from `http::Response<blocking::Body>`
Currently, a blocking::Response
can only be constructed from http::Response
s with a non-blocking Body
:
https://github.com/seanmonstar/reqwest/blob/a0a7db0113bf3df307c4de7219fdfcf70ac0f68a/src/blocking/response.rs#L420
This was probably accidental, as (from what I can tell) other conversions in mod blocking
depend on other blocking::*
.
Unfortunately, changing it now would be backwards-incompatible. We also can't add a second impl From
for the blocking Body
type since the two implementations are potentially-overlapping and will be rejected by rustc
(a type T
could implement Into
for both the async and blocking Body
types). We should perhaps mark said impl
as #[deprecated]
though, with the intent of fixing the impl
in the next major release.
In the meantime we could add an explicit constructor to Response
along the lines of
impl Response {
fn from_http<T: Into<super::Body>>(r: http::Response<T>) -> Self {
// ...
}
}
We'd also internally need a way to convert a blocking::Body
into an async_impl::Body
(possibly using blocking::Body::into_async
, I'm not sure).