Fix: add http timeout & disable keep-alive

This commit is contained in:
kr328 2021-06-13 02:45:20 +08:00
parent 394e406a36
commit 8375fbd8b3

View File

@ -25,13 +25,12 @@ type Status struct {
var client = &http.Client{ var client = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
// from http.DefaultTransport DisableKeepAlives: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second, TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second, ExpectContinueTimeout: 1 * time.Second,
DialContext: dialer.DefaultTunnelDialer, DialContext: dialer.DefaultTunnelDialer,
}, },
Timeout: 60 * time.Second,
} }
func openUrl(url string) (io.ReadCloser, error) { func openUrl(url string) (io.ReadCloser, error) {