Last active
August 2, 2018 14:16
-
-
Save syntheticsh/2aba981ee10898a09be1cc3a4fc2ce35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate hyper; | |
| extern crate futures; | |
| extern crate tokio; | |
| use hyper::{Client, Response, Body}; | |
| use hyper::rt::{Future, Stream}; | |
| use futures::future::join_all; | |
| fn main() { | |
| let client = Client::new(); | |
| let closure = |res: Response<Body>| { | |
| println!("Response: {}", res.status()); | |
| println!("Headers: {:#?}", res.headers()); | |
| res.into_body().concat2() | |
| }; | |
| let mut i = 7; | |
| let mut futures = vec![]; | |
| while i != 0 { | |
| let fut = client | |
| .get("http://httpbin.org/ip".parse().unwrap()) | |
| .and_then(closure); | |
| futures.push(fut); | |
| i -= 1; | |
| } | |
| let work = join_all(futures); | |
| tokio::run(work) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment