From 850ac6d0f06643aa254c871201eae5d66cbea171 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 13 May 2019 16:44:59 +0200 Subject: [PATCH] src/client/http_client.rs: directly return H2Client on upgrade --- src/bin/h2test.rs | 3 +-- src/client/http_client.rs | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bin/h2test.rs b/src/bin/h2test.rs index 60141414..dc5dcd5d 100644 --- a/src/bin/h2test.rs +++ b/src/bin/h2test.rs @@ -15,9 +15,8 @@ fn run() -> Result<(), Error> { let param = json!({"backup-type": "host", "backup-id": "test" }); let upgrade = client.h2upgrade("/api2/json/admin/datastore/store2/backup", Some(param)); - let res = upgrade.and_then(|send_request| { + let res = upgrade.and_then(|h2| { println!("start http2"); - let h2 = H2Client::new(send_request); let result1 = h2.get("test1", None); let result2 = h2.get("test2", None); diff --git a/src/client/http_client.rs b/src/client/http_client.rs index 7c9c63f6..f69a074e 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -242,7 +242,7 @@ impl HttpClient { pub fn h2upgrade( &mut self, path: &str, param: Option - ) -> impl Future, Error=Error> { + ) -> impl Future { let mut req = Self::request_builder(&self.server, "GET", path, param).unwrap(); @@ -279,7 +279,9 @@ impl HttpClient { hyper::rt::spawn(connection); // Wait until the `SendRequest` handle has available capacity. - h2.ready().map_err(Error::from) + h2.ready() + .map(H2Client::new) + .map_err(Error::from) }) }) }