From 30ea80bf31c66c26e83997b1b14bc8b93980a721 Mon Sep 17 00:00:00 2001 From: Sergiu Puscas Date: Mon, 5 Apr 2021 18:27:43 +0200 Subject: [PATCH] Use hyper::body::to_bytes() instead of aggregate(). This should not truncate the content. --- src/rust/api/client.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rust/api/client.rs b/src/rust/api/client.rs index 4960b38642..ee7cb3ee1e 100644 --- a/src/rust/api/client.rs +++ b/src/rust/api/client.rs @@ -2,6 +2,7 @@ use std; use std::error; use std::fmt::{self, Display}; use std::io::{self, Cursor, Read, Seek, SeekFrom, Write}; +use std::iter; use std::str::FromStr; use std::thread::sleep; use std::time::Duration; @@ -808,7 +809,7 @@ pub fn remove_json_null_values(value: &mut json::value::Value) { // Borrowing the body object as mutable and converts it to a string pub async fn get_body_as_string(res_body: &mut hyper::Body) -> String { - let res_body_buf = hyper::body::aggregate(res_body).await.unwrap(); - let res_body_string = String::from_utf8_lossy(res_body_buf.chunk()); + let res_body_buf = hyper::body::to_bytes(res_body).await.unwrap(); + let res_body_string = String::from_utf8_lossy(&res_body_buf); res_body_string.to_string() }