Skip to content

Commit

Permalink
impl From<hyper::Body> for Body (#1236)
Browse files Browse the repository at this point in the history
This implements a conversion from `hyper::Body` to `reqwest::Body`,
which in turn enables converting a `http::Request<hyper::Body>` into
`reqwest::Request` through the existing `TryFrom` implementation.

Fixes #1156.
  • Loading branch information
jonhoo committed Apr 8, 2021
1 parent 1614c5e commit 7d8c327
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/async_impl/body.rs
Expand Up @@ -161,6 +161,18 @@ impl Body {
}
}

impl From<hyper::Body> for Body {
#[inline]
fn from(body: hyper::Body) -> Body {
Self {
inner: Inner::Streaming {
body: Box::pin(WrapHyper(body)),
timeout: None,
},
}
}
}

impl From<Bytes> for Body {
#[inline]
fn from(bytes: Bytes) -> Body {
Expand Down

0 comments on commit 7d8c327

Please sign in to comment.