Added support for sending requests with streaming Body (#545)

This commit is contained in:
Dmitry Pankratov
2019-06-14 19:29:54 +02:00
committed by Sean McArthur
parent 9f256405e5
commit e16aed5e3c
4 changed files with 147 additions and 1 deletions

View File

@@ -137,6 +137,18 @@ impl From<&'static str> for Body {
}
}
impl<I, E> From<Box<dyn Stream<Item = I, Error = E> + Send>> for Body
where
hyper::Chunk: From<I>,
I: 'static,
E: std::error::Error + Send + Sync + 'static,
{
#[inline]
fn from(s: Box<dyn Stream<Item = I, Error = E> + Send>) -> Body {
Body::wrap(::hyper::Body::wrap_stream(s))
}
}
/// A chunk of bytes for a `Body`.
///
/// A `Chunk` can be treated like `&[u8]`.