tweak timeouts

This commit is contained in:
Nazar Kanaev 2020-10-02 15:17:59 +01:00
parent ffc506371c
commit 8007853a9a

View File

@ -8,6 +8,7 @@ import (
"github.com/mmcdole/gofeed" "github.com/mmcdole/gofeed"
"github.com/nkanaev/yarr/storage" "github.com/nkanaev/yarr/storage"
"io/ioutil" "io/ioutil"
"net"
"net/http" "net/http"
"net/url" "net/url"
"time" "time"
@ -258,10 +259,16 @@ func listItems(f storage.Feed) ([]storage.Item, error) {
} }
func init() { func init() {
transport := http.DefaultTransport.(*http.Transport).Clone() transport := &http.Transport{
transport.DisableKeepAlives = true Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 10 * time.Second,
}).DialContext,
DisableKeepAlives: true,
TLSHandshakeTimeout: time.Second * 10,
}
httpClient := &http.Client{ httpClient := &http.Client{
Timeout: time.Second * 5, Timeout: time.Second * 30,
Transport: transport, Transport: transport,
} }
defaultClient = &Client{ defaultClient = &Client{