From 5f0ae8196c8be7444890b3648483357051ce3bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Mon, 20 Nov 2017 19:44:28 -0800 Subject: [PATCH] Add timeout for HTTP client --- reader/http/client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reader/http/client.go b/reader/http/client.go index edb3c86b..5245e415 100644 --- a/reader/http/client.go +++ b/reader/http/client.go @@ -16,6 +16,7 @@ import ( ) const userAgent = "Miniflux " +const requestTimeout = 300 // Client is a HTTP Client :) type Client struct { @@ -63,15 +64,14 @@ func (h *Client) Get() (*Response, error) { } func (h *Client) buildClient() http.Client { + client := http.Client{Timeout: time.Duration(requestTimeout * time.Second)} if h.Insecure { - transport := &http.Transport{ + client.Transport = &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } - - return http.Client{Transport: transport} } - return http.Client{} + return client } func (h *Client) buildHeaders() http.Header {