chiark / gitweb /
server: collect body
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 Aug 2021 16:01:54 +0000 (17:01 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 Aug 2021 16:02:00 +0000 (17:02 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/server.rs
src/prelude.rs

index 0c6cfb63f23056e25abe186345b3da75e72f8025..b956101e681a2fba8c20dc0f5652fc80a1e15ba4 100644 (file)
@@ -244,16 +244,14 @@ async fn run_client(_ic: Arc<InstanceConfig>,
         } = req.ok_or_else(|| anyhow!("webservers all shut down!"))?;
 
         match async {
-          let whole_request =
-            StreamExt::chain(
-              stream::once(Ok(
-                &initial[initial_remaining..]
-              )),
-              body.map_ok(
-                |by| &*by
-              ),
-            )
-            .try_collect().await.context("read request body")?;
+
+          let whole_request = body.try_fold(
+            initial.into_vec(),
+            |mut w, by| async move { w.extend_from_slice(&by); Ok(w) },
+          ).await.context("read request body")?;
+
+          dbg!(whole_request.len());
+
 /*          
 
           multipart::ComponentIterator::resume_mid_component(
index 078dac1a9beb979fbed546031f8905caadc9bb09..10746786cae1a2ea1f0d6781acea29610a94e000 100644 (file)
@@ -28,7 +28,7 @@ pub use std::time::{SystemTime, UNIX_EPOCH};
 pub use cervine::Cow as Cervine;
 pub use extend::ext;
 pub use fehler::{throw, throws};
-pub use futures::{poll, future, StreamExt as _};
+pub use futures::{poll, future, StreamExt, TryStreamExt};
 pub use hyper::body::{Bytes, Buf as _};
 pub use hyper::{Method, Uri};
 pub use hyper_tls::HttpsConnector;