subnet: Avoid general hard timeout for requests (#4478)

This commit is contained in:
Anis Elleuch
2023-02-21 09:32:38 -08:00
committed by GitHub
parent 40e51ee9af
commit 1843bab500
2 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -175,7 +175,7 @@ func subnetAPIKeyAuthHeaders(apiKey string) subnetHeaders {
}
func getSubnetClient() *http.Client {
client := httpClient(10 * time.Second)
client := httpClient(0)
if globalSubnetProxyURL != nil {
client.Transport.(*http.Transport).Proxy = http.ProxyURL(globalSubnetProxyURL)
}
+9 -2
View File
@@ -24,6 +24,7 @@ import (
"fmt"
"math"
"math/rand"
"net"
"net/http"
"os"
"path/filepath"
@@ -425,10 +426,13 @@ func getClient(aliasURL string) *madmin.AdminClient {
return client
}
func httpClient(timeout time.Duration) *http.Client {
func httpClient(reqTimeout time.Duration) *http.Client {
return &http.Client{
Timeout: timeout,
Timeout: reqTimeout,
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: 10 * time.Second,
}).DialContext,
Proxy: ieproxy.GetProxyFunc(),
TLSClientConfig: &tls.Config{
RootCAs: globalRootCAs,
@@ -437,6 +441,9 @@ func httpClient(timeout time.Duration) *http.Client {
// Can't use TLSv1.1 because of RC4 cipher usage
MinVersion: tls.VersionTLS12,
},
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 10 * time.Second,
},
}
}