From 7e91029e0e3614768e3977049eeecd5f49c58908 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 6 Dec 2019 15:29:17 -0800 Subject: [PATCH] docs(client): update client example to use to_bytes --- src/client/mod.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index f53cef55..98222440 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -40,19 +40,9 @@ //! println!("status: {}", res.status()); //! //! // Concatenate the body stream into a single buffer... -//! let mut body = res.into_body(); -//! let mut bytes = Vec::new(); -//! while let Some(next) = body.data().await { -//! let chunk = next?; -//! bytes.extend(chunk); -//! } +//! let buf = hyper::body::to_bytes(res.into_body()).await?; //! -//! // And then, if reading the full body succeeds... -//! // The body is just bytes, but let's print a string... -//! let s = std::str::from_utf8(&bytes) -//! .expect("httpbin sends utf-8 JSON"); -//! -//! println!("body: {}", s); +//! println!("body: {:?}", buf); //! # Ok(()) //! # } //! # fn main () {}