Add timeout for HTTP client
This commit is contained in:
parent
eb9f588216
commit
5f0ae8196c
1 changed files with 4 additions and 4 deletions
|
@ -16,6 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const userAgent = "Miniflux <https://miniflux.net/>"
|
const userAgent = "Miniflux <https://miniflux.net/>"
|
||||||
|
const requestTimeout = 300
|
||||||
|
|
||||||
// Client is a HTTP Client :)
|
// Client is a HTTP Client :)
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
@ -63,15 +64,14 @@ func (h *Client) Get() (*Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Client) buildClient() http.Client {
|
func (h *Client) buildClient() http.Client {
|
||||||
|
client := http.Client{Timeout: time.Duration(requestTimeout * time.Second)}
|
||||||
if h.Insecure {
|
if h.Insecure {
|
||||||
transport := &http.Transport{
|
client.Transport = &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
return http.Client{Transport: transport}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return http.Client{}
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Client) buildHeaders() http.Header {
|
func (h *Client) buildHeaders() http.Header {
|
||||||
|
|
Loading…
Reference in a new issue