From: Ian Jackson Date: Thu, 29 Jul 2021 00:47:45 +0000 (+0100) Subject: client: wip code X-Git-Tag: hippotat/1.0.0~429 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=128970f62442882300f43c15d2c168421b8ff638;p=hippotat.git client: wip code Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index 3feefc0..18ba185 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -44,7 +44,9 @@ where C: hyper::client::connect::Connect + Clone + Send + Sync + 'static, let stream_for_rx = ipif.stdin .take().unwrap(); - let mut reqs = Vec::with_capacity(ic.max_requests_outstanding.sat()); + let mut reqs: Vec> + >>> = Vec::with_capacity(ic.max_requests_outstanding.sat()); // xxx check that ic settings are all honoured @@ -105,7 +107,7 @@ where C: hyper::client::connect::Connect + Clone + Send + Sync + 'static, } let resp = resp.into_body(); // xxx: some size limit to avoid mallocing the universe - let resp = hyper::body::aggregate(resp).await + let resp = hyper::body::to_bytes(resp).await .context("HTTP error fetching response body")?; Ok::<_,AE>(resp) }).await? }.await; @@ -117,7 +119,8 @@ where C: hyper::client::connect::Connect + Clone + Send + Sync + 'static, reqs.push(fut); } - (got, goti, _) = future::select_all(&mut reqs) => + (got, goti, _) = async { future::select_all(&mut reqs).await }, + if ! reqs.is_empty() => { reqs.swap_remove(goti); if let Some(got) = reporter.report(got) { diff --git a/src/prelude.rs b/src/prelude.rs index 7194967..8407c02 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -8,6 +8,7 @@ pub use std::borrow::Cow; pub use std::cmp::{min, max}; pub use std::fs; pub use std::fmt::{self, Debug, Display}; +pub use std::future::Future; pub use std::io::{self, ErrorKind, Read as _}; pub use std::iter; pub use std::mem; @@ -15,6 +16,7 @@ pub use std::net::{IpAddr, Ipv4Addr}; pub use std::path::{Path, PathBuf}; pub use std::panic; pub use std::process; +pub use std::pin::Pin; pub use std::str::FromStr; pub use std::sync::Arc; pub use std::task::Poll;