chiark / gitweb /
client: wip code
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 29 Jul 2021 00:47:45 +0000 (01:47 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 29 Jul 2021 00:47:45 +0000 (01:47 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs
src/prelude.rs

index 3feefc0fef8c1a18d66a41625c034eff0f7f7441..18ba185f0ce5e0059d4454f1595fc408569836a5 100644 (file)
@@ -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<Pin<Box<
+      dyn Future<Output=Result<Bytes,AE>>
+      >>> = 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) {
index 7194967da6250dc5ef4f36ff02619b15af061b6c..8407c02e6856c8c365d48d5592cc850aa9f33b83 100644 (file)
@@ -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;