diff --git a/client.go b/client.go index 55466888..06df9e2c 100644 --- a/client.go +++ b/client.go @@ -658,7 +658,7 @@ func (c *Client) SetCommonDumpOptions(opt *DumpOptions) *Client { // SetProxy set the proxy function. func (c *Client) SetProxy(proxy func(*http.Request) (*urlpkg.URL, error)) *Client { - c.t.Proxy = proxy + c.t.SetProxy(proxy) return c } @@ -681,7 +681,8 @@ func (c *Client) SetProxyURL(proxyUrl string) *Client { c.log.Errorf("failed to parse proxy url %s: %v", proxyUrl, err) return c } - c.t.Proxy = http.ProxyURL(u) + proxy := http.ProxyURL(u) + c.t.SetProxy(proxy) return c } @@ -732,22 +733,22 @@ func (c *Client) SetXmlUnmarshal(fn func(data []byte, v interface{}) error) *Cli } // SetDialTLS set the customized `DialTLSContext` function to Transport. -// Make sure the returned `conn` implements TLSConn if you want your +// Make sure the returned `conn` implements pkg/tls.Conn if you want your // customized `conn` supports HTTP2. func (c *Client) SetDialTLS(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Client { - c.t.DialTLSContext = fn + c.t.SetDialTLS(fn) return c } // SetDial set the customized `DialContext` function to Transport. func (c *Client) SetDial(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Client { - c.t.DialContext = fn + c.t.SetDial(fn) return c } // SetTLSHandshakeTimeout set the TLS handshake timeout. func (c *Client) SetTLSHandshakeTimeout(timeout time.Duration) *Client { - c.t.TLSHandshakeTimeout = timeout + c.t.SetTLSHandshakeTimeout(timeout) return c } diff --git a/client_wrapper.go b/client_wrapper.go index 56c5e0bf..30b8430b 100644 --- a/client_wrapper.go +++ b/client_wrapper.go @@ -442,6 +442,18 @@ func EnableForceHTTP2() *Client { return defaultClient.EnableForceHTTP2() } +// EnableForceHTTP3 is a global wrapper methods which delegated +// to the default client's EnableForceHTTP3. +func EnableForceHTTP3() *Client { + return defaultClient.EnableForceHTTP3() +} + +// EnableHTTP3 is a global wrapper methods which delegated +// to the default client's EnableHTTP3. +func EnableHTTP3() *Client { + return defaultClient.EnableHTTP3() +} + // DisableForceHttpVersion is a global wrapper methods which delegated // to the default client's DisableForceHttpVersion. func DisableForceHttpVersion() *Client { diff --git a/client_wrapper_test.go b/client_wrapper_test.go index bf9496f5..40a1ab48 100644 --- a/client_wrapper_test.go +++ b/client_wrapper_test.go @@ -102,6 +102,8 @@ func TestGlobalWrapper(t *testing.T) { SetRedirectPolicy(NoRedirectPolicy()), EnableForceHTTP1(), EnableForceHTTP2(), + EnableForceHTTP3(), + EnableHTTP3(), DisableForceHttpVersion(), SetAutoDecodeContentType("json"), SetAutoDecodeContentTypeFunc(func(contentType string) bool { return true }),