fix: add deadline conns and dnsCache for remote transports (#16865)

This commit is contained in:
Harshavardhana 2023-03-21 08:49:20 -07:00 committed by GitHub
parent 12047702f5
commit 0448728228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -639,6 +639,7 @@ const defaultDialTimeout = 5 * time.Second
// NewHTTPTransportWithTimeout allows setting a timeout.
func NewHTTPTransportWithTimeout(timeout time.Duration) *http.Transport {
return xhttp.ConnSettings{
DialContext: newCustomDialContext(),
DNSCache: globalDNSCache,
DialTimeout: defaultDialTimeout,
RootCAs: globalRootCAs,
@ -674,6 +675,7 @@ func newCustomDialContext() dialContext {
func NewRemoteTargetHTTPTransport() func() *http.Transport {
return xhttp.ConnSettings{
DialContext: newCustomDialContext(),
DNSCache: globalDNSCache,
RootCAs: globalRootCAs,
EnableHTTP2: false,
}.NewRemoteTargetHTTPTransport()