From e3dbd41b201556e3aa8d22e0938251cee215a975 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 14 May 2019 14:54:21 +0200 Subject: [PATCH] src/client/http_client.rs: add flow control for h2 upload --- src/client.rs | 2 ++ src/client/http_client.rs | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/client.rs b/src/client.rs index 3069f799..4ba7a803 100644 --- a/src/client.rs +++ b/src/client.rs @@ -3,6 +3,8 @@ //! This library implements the client side to access the backups //! server using https. +mod pipe_to_stream; + mod http_client; pub use http_client::*; diff --git a/src/client/http_client.rs b/src/client/http_client.rs index 857adc40..c27d5932 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -16,6 +16,7 @@ use serde_json::{json, Value}; use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use crate::tools::{self, BroadcastFuture, tty}; +use super::pipe_to_stream::*; #[derive(Clone)] struct AuthInfo { @@ -414,12 +415,13 @@ impl H2Client { .ready() .map_err(Error::from) .and_then(move |mut send_request| { - let (response, mut stream) = send_request.send_request(request, false).unwrap(); - // fixme: implement flow control - stream.send_data(bytes::Bytes::from(data), true); - response - .map_err(Error::from) - .and_then(Self::h2api_response) + let (response, stream) = send_request.send_request(request, false).unwrap(); + PipeToSendStream::new(bytes::Bytes::from(data), stream) + .and_then(|_| { + response + .map_err(Error::from) + .and_then(Self::h2api_response) + }) }) }