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

index 78f0cba56dd0f1459c0fd5b60befe0c7d476a433..6cdb45c94ac3e86089d6f881cf16efde60b64059 100644 (file)
@@ -83,31 +83,33 @@ where C: hyper::client::connect::Connect + Clone + Send + Sync,
           assert!( to_process.is_none() );
           dbg!(&reqs.len(), &upbound_total, &upbound.len());
 
-          let req = hyper::Request::post(&ic.url)
-            .body(
+          let body = hyper::body::Body::wrap_stream(
               Itertools::intersperse(
                 upbound.into_iter().map(|u| Cow::from(u)),
                 Cow::from(&[SLIP_END] as &'static [u8])
-              )
-            ).context("construct request")?;
+              ).into()
+          );
+
+          let req = hyper::Request::post(&ic.url).body(body)
+            .context("construct request")?;
 
           let resp = hclient.request(req);
           let fut = Box::pin(tokio::time::timeout(
             ic.http_timeout,
             async {
               let r = async {
-                let resp = resp.await;
+                let resp = resp.await.context("make request")?;
                 if ! resp.status().is_success() {
                   throw!(anyhow!("HTTP error status {}", &resp.status()));
                 }
                 let resp = resp.into_body();
                 // xxx: some size limit to avoid mallocing the universe
-                let resp = resp.aggregate().await
+                let resp = hyper::body::aggregate(resp).await
                   .context("HTTP error fetching response body")?;
                 Ok::<_,AE>(resp)
-              };
+              }.await;
               if r.is_err() {
-                tokio::time::sleep(&ic.http_retry).await;
+                tokio::time::sleep(ic.http_retry).await;
               }
               r
             }
index b87417b33f4a2f5a7cf0626efd6fd9690efee2b2..bb6cc362e8b9f9e52739134ad42219ca05a86120 100644 (file)
@@ -8,7 +8,7 @@ pub struct Reporter {
 }
 
 impl Reporter {
-  pub fn report<T>(r: Result<T,AE>) -> Option<T> {
+  pub fn report<T>(&mut self, r: Result<T,AE>) -> Option<T> {
     match r {
       Ok(t) => {
         // xxx something something success