Skip to content

Commit 252ff6f

Browse files
Julien Pivottoroidelapluie
authored andcommitted
Make HTTP2 user visible
We still get reports from users that have issues with HTTP2. Let's make it explicitly possible to disable it. Because we previously introduced FollowRedirects, most lib users already use our defaults. Signed-off-by: Julien Pivotto <[email protected]>
1 parent 0762b59 commit 252ff6f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

config/http_config.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"net"
2929
"net/http"
3030
"net/url"
31-
"os"
3231
"strings"
3332
"sync"
3433
"time"
@@ -43,6 +42,7 @@ import (
4342
// DefaultHTTPClientConfig is the default HTTP client configuration.
4443
var DefaultHTTPClientConfig = HTTPClientConfig{
4544
FollowRedirects: true,
45+
EnableHTTP2: true,
4646
}
4747

4848
// defaultHTTPClientOptions holds the default HTTP client options.
@@ -198,6 +198,10 @@ type HTTPClientConfig struct {
198198
// The omitempty flag is not set, because it would be hidden from the
199199
// marshalled configuration when set to false.
200200
FollowRedirects bool `yaml:"follow_redirects" json:"follow_redirects"`
201+
// EnableHTTP2 specifies whether the client should configure HTTP2.
202+
// The omitempty flag is not set, because it would be hidden from the
203+
// marshalled configuration when set to false.
204+
EnableHTTP2 bool `yaml:"enable_http2" json:"enable_http2"`
201205
}
202206

203207
// SetDirectory joins any relative file paths with dir.
@@ -401,7 +405,7 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
401405
ExpectContinueTimeout: 1 * time.Second,
402406
DialContext: dialContext,
403407
}
404-
if opts.http2Enabled && os.Getenv("PROMETHEUS_COMMON_DISABLE_HTTP2") == "" {
408+
if opts.http2Enabled && cfg.EnableHTTP2 {
405409
// HTTP/2 support is golang had many problematic cornercases where
406410
// dead connections would be kept and used in connection pools.
407411
// https://github.com/golang/go/issues/32388

config/testdata/http.conf.good.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ basic_auth:
22
username: username
33
password: "mysecret"
44
proxy_url: "http://remote.host"
5+
enable_http2: true

0 commit comments

Comments
 (0)