How to set timeout for HTTP request with hyper, tokio and futures in Rust?
问题 How do I set a timeout for HTTP request using asynchronous Hyper (>= 0.11)? Here is the example of the code without timeout: extern crate hyper; extern crate tokio_core; extern crate futures; use futures::Future; use hyper::Client; use tokio_core::reactor::Core; fn main() { let mut core = Core::new().unwrap(); let client = Client::new(&core.handle()); let uri = "http://stackoverflow.com".parse().unwrap(); let work = client.get(uri).map(|res| { res.status() }); match core.run(work) { Ok(status