server/rest: fix type ambiguity

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-03-29 12:00:38 +02:00
parent d43c407a00
commit eeff085d9d

View File

@ -315,18 +315,19 @@ async fn get_request_parameters<S: 'static + BuildHasher + Send>(
} }
} }
let body = req_body let body = TryStreamExt::map_err(req_body, |err| {
.map_err(|err| http_err!(BAD_REQUEST, "Promlems reading request 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? .try_fold(Vec::new(), |mut acc, chunk| async move {
if acc.len() + chunk.len() < 64 * 1024 { // FIXME: max request body size?
acc.extend_from_slice(&*chunk); if acc.len() + chunk.len() < 64 * 1024 {
Ok(acc) acc.extend_from_slice(&*chunk);
} else { Ok(acc)
Err(http_err!(BAD_REQUEST, "Request body too large")) } else {
} Err(http_err!(BAD_REQUEST, "Request body too large"))
}) }
.await?; })
.await?;
let utf8_data = let utf8_data =
std::str::from_utf8(&body).map_err(|err| format_err!("Request body not uft8: {}", err))?; std::str::from_utf8(&body).map_err(|err| format_err!("Request body not uft8: {}", err))?;