mirror of
https://github.com/projectdiscovery/httpx
synced 2026-06-08 16:50:17 +00:00
Merge pull request #2424 from Veirt/fix/http11-retry-fallback-2240
fix(httpx): keep retry fallback on HTTP/1.1 when -pr http11 is set
This commit is contained in:
@@ -153,7 +153,7 @@ func New(options *Options) (*HTTPX, error) {
|
||||
DisableKeepAlives: true,
|
||||
}
|
||||
|
||||
if httpx.Options.Protocol == "http11" {
|
||||
if httpx.Options.Protocol == HTTP11 {
|
||||
// disable http2
|
||||
_ = os.Setenv("GODEBUG", "http2client=0")
|
||||
transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
|
||||
@@ -183,6 +183,10 @@ func New(options *Options) (*HTTPX, error) {
|
||||
CheckRedirect: redirectFunc,
|
||||
}, retryablehttpOptions)
|
||||
|
||||
if httpx.Options.Protocol == HTTP11 {
|
||||
httpx.client.HTTPClient2 = httpx.client.HTTPClient
|
||||
}
|
||||
|
||||
transport2 := &http2.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
|
||||
@@ -28,3 +28,22 @@ func TestDo(t *testing.T) {
|
||||
require.Greater(t, len(resp.Raw), 800)
|
||||
})
|
||||
}
|
||||
|
||||
func TestHTTP11DisablesRetryableHTTP2FallbackClient(t *testing.T) {
|
||||
options := DefaultOptions
|
||||
options.Protocol = HTTP11
|
||||
|
||||
ht, err := New(&options)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, ht.client)
|
||||
require.Same(t, ht.client.HTTPClient, ht.client.HTTPClient2)
|
||||
}
|
||||
|
||||
func TestDefaultProtocolKeepsRetryableHTTP2FallbackClient(t *testing.T) {
|
||||
options := DefaultOptions
|
||||
|
||||
ht, err := New(&options)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, ht.client)
|
||||
require.NotSame(t, ht.client.HTTPClient, ht.client.HTTPClient2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user