diff options
Diffstat (limited to 'async-await/src/hyper.rs')
-rw-r--r-- | async-await/src/hyper.rs | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/async-await/src/hyper.rs b/async-await/src/hyper.rs deleted file mode 100644 index 37332ee4..00000000 --- a/async-await/src/hyper.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![feature(await_macro, async_await)] - -use tokio::async_wait; -use tokio::prelude::*; -use hyper::Client; - -use std::time::Duration; -use std::str; - -#[tokio::main] -async fn main() { - let client = Client::new(); - - let uri = "http://httpbin.org/ip".parse().unwrap(); - - let response = async_wait!({ - client.get(uri) - .timeout(Duration::from_secs(10)) - }).unwrap(); - - println!("Response: {}", response.status()); - - let mut body = response.into_body(); - - while let Some(chunk) = async_wait!(body.next()) { - let chunk = chunk.unwrap(); - println!("chunk = {}", str::from_utf8(&chunk[..]).unwrap()); - } -} |