}
#[throws(ReadLimitedError)]
-pub async fn read_limited_bytes<S>(limit: usize, stream: &mut S) -> Box<[u8]>
+pub async fn read_limited_bytes<S>(limit: usize, initial: Box<[u8]>,
+ stream: &mut S) -> Box<[u8]>
where S: futures::Stream<Item=Result<hyper::body::Bytes,hyper::Error>>
+ Debug + Unpin,
// we also require that the Stream is cancellation-safe
{
- let mut accum = vec![];
+ let mut accum = initial.into_vec();
while let Some(item) = stream.next().await {
let b = item?;
accum.extend(b);