Skip to content

Commit

Permalink
Add proxy Body::collect_bytes for easier unit tests (#1445)
Browse files Browse the repository at this point in the history
* Expose `Body::collect` for easier unit tests

Avoids people having to pull in `http_body_util` for the `BodyExt`

Signed-off-by: clux <sszynrae@gmail.com>

* avoid opaque Collect and Collected and await + into_bytes instead

Signed-off-by: clux <sszynrae@gmail.com>

* Update kube-client/src/client/body.rs

Co-authored-by: Matei David <matei.david.35@gmail.com>
Signed-off-by: Eirik A <sszynrae@gmail.com>

* Update kube-client/src/client/body.rs

Co-authored-by: Matei David <matei.david.35@gmail.com>
Signed-off-by: Eirik A <sszynrae@gmail.com>

---------

Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: Eirik A <sszynrae@gmail.com>
Co-authored-by: Matei David <matei.david.35@gmail.com>
  • Loading branch information
clux and mateiidavid authored Apr 2, 2024
1 parent 067b68d commit db7878e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kube-client/src/client/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ impl Body {
Body::new(Kind::Wrap(body.map_err(Into::into).boxed_unsync()))
}

/// Collect all the data frames and trailers of the request body
pub async fn collect_bytes(self) -> Result<Bytes, crate::Error> {
Ok(self.collect().await?.to_bytes())
}

pub(crate) fn into_data_stream(
self,
) -> impl Stream<Item = Result<<Self as HttpBody>::Data, <Self as HttpBody>::Error>> {
Expand Down

0 comments on commit db7878e

Please sign in to comment.