diff --git a/common/httpx/httpx.go b/common/httpx/httpx.go index 039f4c4c..ecbc4c66 100644 --- a/common/httpx/httpx.go +++ b/common/httpx/httpx.go @@ -183,6 +183,10 @@ func New(options *Options) (*HTTPX, error) { CheckRedirect: redirectFunc, }, retryablehttpOptions) + if httpx.Options.Protocol == "http11" { + httpx.client.HTTPClient2 = nil + } + transport2 := &http2.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, diff --git a/common/httpx/httpx_test.go b/common/httpx/httpx_test.go index 7da6ad12..be22a85b 100644 --- a/common/httpx/httpx_test.go +++ b/common/httpx/httpx_test.go @@ -28,3 +28,13 @@ func TestDo(t *testing.T) { require.Greater(t, len(resp.Raw), 800) }) } + +func TestHTTP11ShouldDisableRetryableHTTP2Fallback(t *testing.T) { + opts := DefaultOptions + opts.Protocol = "http11" + + ht, err := New(&opts) + require.NoError(t, err) + + require.Nil(t, ht.client.HTTPClient2, "when protocol is http11, retryablehttp HTTPClient2 fallback should be disabled") +}