From ff7fcd09923a933818f50d6f985a34040337f7bf Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Sat, 2 Jul 2016 13:16:31 +0400 Subject: [PATCH] add client timeout (#1526) --- parity/price_info.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/parity/price_info.rs b/parity/price_info.rs index ad25f31da..0c04b3a77 100644 --- a/parity/price_info.rs +++ b/parity/price_info.rs @@ -28,10 +28,12 @@ impl PriceInfo { pub fn get() -> Option { let mut body = String::new(); // TODO: Handle each error type properly - Client::new() - .get("http://api.etherscan.io/api?module=stats&action=ethprice") + let mut client = Client::new(); + client.set_read_timeout(Some(::std::time::Duration::from_secs(3))); + client.get("http://api.etherscan.io/api?module=stats&action=ethprice") .header(Connection::close()) - .send().ok() + .send() + .ok() .and_then(|mut s| s.read_to_string(&mut body).ok()) .and_then(|_| Json::from_str(&body).ok()) .and_then(|json| json.find_path(&["result", "ethusd"])