async-await: streaming hyper body example (#656)

Add reading the hyper body in the async/await example.
This commit is contained in:
Carl Lerche
2018-09-21 19:58:46 -07:00
committed by GitHub
parent 1119d572ee
commit ffd73a64e7
+8
View File
@@ -8,6 +8,7 @@ use tokio::prelude::*;
use hyper::Client;
use std::time::Duration;
use std::str;
pub fn main() {
tokio::run_async(async {
@@ -21,5 +22,12 @@ pub fn main() {
}).unwrap();
println!("Response: {}", response.status());
let mut body = response.into_body();
while let Some(chunk) = await!(body.next()) {
let chunk = chunk.unwrap();
println!("chunk = {}", str::from_utf8(&chunk[..]).unwrap());
}
});
}