docs(client): update client example to use to_bytes

This commit is contained in:
Sean McArthur
2019-12-06 15:29:17 -08:00
parent 245fa9c44c
commit 7e91029e0e

View File

@@ -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 () {}