From f0c38b4d7968332dab22d83d7bd0f8b41d9552c5 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Wed, 1 May 2019 18:02:38 -0400 Subject: [PATCH] Set timeout on requests --- src/updater.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/updater.rs b/src/updater.rs index 0623b3f..105e6d2 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -5,6 +5,7 @@ use crate::{ }; use chrono::prelude::*; use reqwest::{Client, RedirectPolicy, Url, UrlError}; +use std::time::Duration; pub fn update_state(state: State) { let new_statuses = { Some(update_status(&state.read().unwrap().config)) }; @@ -20,7 +21,7 @@ pub fn update_status(config: &Config) -> Vec { for website_conf in &config.websites { let mut group = Vec::with_capacity(website_conf.endpoints.len()); for endpoint in &website_conf.endpoints { - let mut client_builder = Client::builder(); + let mut client_builder = Client::builder().timeout(Some(Duration::from_secs(5))); if let Some(false) = endpoint.follow_redirects { client_builder = client_builder.redirect(RedirectPolicy::none());