From 984a7c3502ef323405bcb48483c685e9a3d3b6f4 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 28 Jun 2019 07:02:43 +0200 Subject: [PATCH] src/client/http_client.rs - h2 download: implement flow control --- src/client/http_client.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/http_client.rs b/src/client/http_client.rs index f6f8ed66..914ba28d 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -1001,10 +1001,14 @@ impl H2Client { .and_then(|_| { bail!("unknown error"); }) ) } else { + let mut body = resp.into_body(); + let mut release_capacity = body.release_capacity().clone(); + future::Either::B( - resp.into_body() + body .map_err(Error::from) .fold(output, move |mut acc, chunk| { + let _ = release_capacity.release_capacity(chunk.len()); acc.write_all(&chunk)?; Ok::<_, Error>(acc) })