aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2017-11-20 19:44:28 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2017-11-20 19:44:28 -0800
commit5f0ae8196c8be7444890b3648483357051ce3bed (patch)
tree156e220892b92157387fe2056ae7cb6eeeeb9cb6
parenteb9f5882167058ddf754803b3506e3fce61090b6 (diff)
Add timeout for HTTP client
-rw-r--r--reader/http/client.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/reader/http/client.go b/reader/http/client.go
index edb3c86..5245e41 100644
--- a/reader/http/client.go
+++ b/reader/http/client.go
@@ -16,6 +16,7 @@ import (
)
const userAgent = "Miniflux <https://miniflux.net/>"
+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 {