From 7d8c32784e543b1a2b9536a70db466c0250876c2 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Thu, 8 Apr 2021 16:21:29 -0400 Subject: [PATCH] impl From for Body (#1236) This implements a conversion from `hyper::Body` to `reqwest::Body`, which in turn enables converting a `http::Request` into `reqwest::Request` through the existing `TryFrom` implementation. Fixes #1156. --- src/async_impl/body.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs index 5d12d05..d469c59 100644 --- a/src/async_impl/body.rs +++ b/src/async_impl/body.rs @@ -161,6 +161,18 @@ impl Body { } } +impl From for Body { + #[inline] + fn from(body: hyper::Body) -> Body { + Self { + inner: Inner::Streaming { + body: Box::pin(WrapHyper(body)), + timeout: None, + }, + } + } +} + impl From for Body { #[inline] fn from(bytes: Bytes) -> Body {