From 10b816d2fbd9e09c27535afb647bc9fcc4010c5a Mon Sep 17 00:00:00 2001 From: clux Date: Tue, 26 Mar 2024 17:32:37 +0000 Subject: [PATCH 1/4] Expose `Body::collect` for easier unit tests Avoids people having to pull in `http_body_util` for the `BodyExt` Signed-off-by: clux --- kube-client/src/client/body.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kube-client/src/client/body.rs b/kube-client/src/client/body.rs index 62adcffdd..1f2d85cfd 100644 --- a/kube-client/src/client/body.rs +++ b/kube-client/src/client/body.rs @@ -44,6 +44,11 @@ impl Body { { Body::new(Kind::Wrap(body.map_err(Into::into).boxed_unsync())) } + + /// Collect all the pieces of the body + pub fn collect(self) -> http_body_util::combinators::Collect { + ::collect(self) + } } impl From for Body { From a5ac263a8fcbe6b97b073bf325f7f2f1eff61b87 Mon Sep 17 00:00:00 2001 From: clux Date: Tue, 26 Mar 2024 21:27:14 +0000 Subject: [PATCH 2/4] avoid opaque Collect and Collected and await + into_bytes instead Signed-off-by: clux --- kube-client/src/client/body.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kube-client/src/client/body.rs b/kube-client/src/client/body.rs index 1f2d85cfd..c3cdb2dc3 100644 --- a/kube-client/src/client/body.rs +++ b/kube-client/src/client/body.rs @@ -46,8 +46,8 @@ impl Body { } /// Collect all the pieces of the body - pub fn collect(self) -> http_body_util::combinators::Collect { - ::collect(self) + pub async fn collect_bytes(self) -> Result { + Ok(::collect(self).await?.to_bytes()) } } From e458104bd78667e4c38fa92b4c3e263effb4fb2e Mon Sep 17 00:00:00 2001 From: Eirik A Date: Tue, 2 Apr 2024 19:01:23 +0100 Subject: [PATCH 3/4] Update kube-client/src/client/body.rs Co-authored-by: Matei David Signed-off-by: Eirik A --- kube-client/src/client/body.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube-client/src/client/body.rs b/kube-client/src/client/body.rs index 521912258..b5d01069c 100644 --- a/kube-client/src/client/body.rs +++ b/kube-client/src/client/body.rs @@ -44,7 +44,7 @@ impl Body { Body::new(Kind::Wrap(body.map_err(Into::into).boxed_unsync())) } - /// Collect all the pieces of the body + /// Collect all the data frames and trailers of the request body pub async fn collect_bytes(self) -> Result { Ok(::collect(self).await?.to_bytes()) } From 0a70c7d206a98a1aabb2b8cdb04fe84a74ca42a8 Mon Sep 17 00:00:00 2001 From: Eirik A Date: Tue, 2 Apr 2024 19:01:28 +0100 Subject: [PATCH 4/4] Update kube-client/src/client/body.rs Co-authored-by: Matei David Signed-off-by: Eirik A --- kube-client/src/client/body.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube-client/src/client/body.rs b/kube-client/src/client/body.rs index b5d01069c..981d685db 100644 --- a/kube-client/src/client/body.rs +++ b/kube-client/src/client/body.rs @@ -46,7 +46,7 @@ impl Body { /// Collect all the data frames and trailers of the request body pub async fn collect_bytes(self) -> Result { - Ok(::collect(self).await?.to_bytes()) + Ok(self.collect().await?.to_bytes()) } pub(crate) fn into_data_stream(