Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/httpx/httpx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions common/httpx/httpx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}