Set timeout on requests

This commit is contained in:
Edward Shen 2019-05-01 18:02:38 -04:00
parent e88efdae56
commit f0c38b4d79
Signed by: edward
GPG key ID: F350507060ED6C90

View file

@ -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<StatusGroup> {
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());