Use cleanhttp.DefaultPooledTransport for the default API client (#12409)

The only difference is DefaultTransport sets DisableKeepAlives

This doesn't make much sense to me - every http connection from the
nomad client goes to the same NOMAD_ADDR so it's a great case for keep
alive. Except round robin DNS and anycast perhaps.

Consul does this already
1e47e3c82b/api/api.go (L397)
This commit is contained in:
Benjamin Buzbee
2022-04-06 08:34:55 -07:00
committed by GitHub
parent cf6ca95f79
commit 6e1270dd08
2 changed files with 4 additions and 1 deletions

3
.changelog/12409.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:improvement
api: default to using DefaultPooledTransport client to support keep-alive by default
```

View File

@@ -264,7 +264,7 @@ func (t *TLSConfig) Copy() *TLSConfig {
}
func defaultHttpClient() *http.Client {
httpClient := cleanhttp.DefaultClient()
httpClient := cleanhttp.DefaultPooledClient()
transport := httpClient.Transport.(*http.Transport)
transport.TLSHandshakeTimeout = 10 * time.Second
transport.TLSClientConfig = &tls.Config{