diff --git a/api-test/Cargo.toml b/api-test/Cargo.toml index 112d7c63..555b1625 100644 --- a/api-test/Cargo.toml +++ b/api-test/Cargo.toml @@ -13,7 +13,7 @@ endian_trait = { version = "0.6", features = [ "arrays" ] } failure = "0.1" futures-preview = "0.3.0-alpha" http = "0.1" -hyper = { version = "0.13.0-alpha.1" } +hyper = { version = "0.13.0-alpha.2" } lazy_static = "1.3" proxmox = { path = "../proxmox", features = [ "api-macro" ] } regex = "1.1" diff --git a/api-test/src/bin/api-test.rs b/api-test/src/bin/api-test.rs index 2dbff9a9..0a200b82 100644 --- a/api-test/src/bin/api-test.rs +++ b/api-test/src/bin/api-test.rs @@ -179,6 +179,14 @@ async fn update_mount_point(id: String, entry: MountEntry) -> Result Result { + let mut data = Vec::new(); + while let Some(chunk) = body.next().await { + data.extend(chunk?); + } + Ok(serde_json::from_str(std::str::from_utf8(&data)?)?) +} + async fn route_request(request: Request) -> Result, Error> { let (parts, body) = request.into_parts(); let path = parts.uri.path(); @@ -198,9 +206,7 @@ async fn route_request(request: Request) -> Result, E if let Some(ty) = parts.headers.get(http::header::CONTENT_TYPE) { if ty.to_str()? == "application/json" { - use futures::stream::TryStreamExt; - let json = - serde_json::from_str(std::str::from_utf8(body.try_concat().await?.as_ref())?)?; + let json = json_body(body).await?; match json { Value::Object(map) => { for (k, v) in map {