From eeff085d9d09028aba722d4106634e2f9c9ce931 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 29 Mar 2021 12:00:38 +0200 Subject: [PATCH] server/rest: fix type ambiguity Signed-off-by: Thomas Lamprecht --- src/server/rest.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/server/rest.rs b/src/server/rest.rs index 75a29d49..150125ec 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -315,18 +315,19 @@ async fn get_request_parameters( } } - let body = req_body - .map_err(|err| http_err!(BAD_REQUEST, "Promlems reading request body: {}", err)) - .try_fold(Vec::new(), |mut acc, chunk| async move { - // FIXME: max request body size? - if acc.len() + chunk.len() < 64 * 1024 { - acc.extend_from_slice(&*chunk); - Ok(acc) - } else { - Err(http_err!(BAD_REQUEST, "Request body too large")) - } - }) - .await?; + let body = TryStreamExt::map_err(req_body, |err| { + http_err!(BAD_REQUEST, "Problems reading request body: {}", err) + }) + .try_fold(Vec::new(), |mut acc, chunk| async move { + // FIXME: max request body size? + if acc.len() + chunk.len() < 64 * 1024 { + acc.extend_from_slice(&*chunk); + Ok(acc) + } else { + Err(http_err!(BAD_REQUEST, "Request body too large")) + } + }) + .await?; let utf8_data = std::str::from_utf8(&body).map_err(|err| format_err!("Request body not uft8: {}", err))?;