From 8a199f4d7441c09c388dcc8527064ae3aa8b0873 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 15 Aug 2021 17:01:54 +0100 Subject: [PATCH] server: collect body Signed-off-by: Ian Jackson --- src/bin/server.rs | 18 ++++++++---------- src/prelude.rs | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/bin/server.rs b/src/bin/server.rs index 0c6cfb6..b956101 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -244,16 +244,14 @@ async fn run_client(_ic: Arc, } = 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( diff --git a/src/prelude.rs b/src/prelude.rs index 078dac1..1074678 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -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; -- 2.30.2