Skip to content
Closed
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
9 changes: 9 additions & 0 deletions common/httpx/httpx.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ func New(options *Options) (*HTTPX, error) {
CheckRedirect: redirectFunc,
}, retryablehttpOptions)

if httpx.Options.Protocol == "http11" {
// keep retry fallback on the same client so explicit HTTP/1.1 is preserved
httpx.client.HTTPClient2 = httpx.client.HTTPClient
}

transport2 := &http2.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
Expand Down Expand Up @@ -455,3 +460,7 @@ func (httpx *HTTPX) Sanitize(respStr string, trimLine, normalizeSpaces bool) str
}
return respStr
}




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 TestHTTP11ProtocolDisablesHTTP2FallbackClient(t *testing.T) {
opts := DefaultOptions
opts.Protocol = HTTP11

ht, err := New(&opts)
require.Nil(t, err)
require.NotNil(t, ht.client)
require.Equal(t, ht.client.HTTPClient, ht.client.HTTPClient2)
}