@@ -27,14 +27,26 @@ import (
2727)
2828
2929// DefaultRoundTripper is used if no RoundTripper is set in Config.
30- var DefaultRoundTripper http.RoundTripper = & http.Transport {
31- Proxy : http .ProxyFromEnvironment ,
32- DialContext : (& net.Dialer {
33- Timeout : 30 * time .Second ,
34- KeepAlive : 30 * time .Second ,
35- }).DialContext ,
36- TLSHandshakeTimeout : 10 * time .Second ,
37- }
30+ var DefaultRoundTripper http.RoundTripper = func () http.RoundTripper {
31+ if t , ok := http .DefaultTransport .(* http.Transport ); ok {
32+ return t .Clone ()
33+ }
34+
35+ //If unable to clone construct and return
36+ //refer https://github.com/golang/go/blob/master/src/net/http/transport.go#L46
37+ return & http.Transport {
38+ Proxy : http .ProxyFromEnvironment ,
39+ DialContext : (& net.Dialer {
40+ Timeout : 30 * time .Second ,
41+ KeepAlive : 30 * time .Second ,
42+ }).DialContext ,
43+ ForceAttemptHTTP2 : true ,
44+ MaxIdleConns : 100 ,
45+ IdleConnTimeout : 90 * time .Second ,
46+ TLSHandshakeTimeout : 10 * time .Second ,
47+ ExpectContinueTimeout : 1 * time .Second ,
48+ }
49+ }()
3850
3951// Config defines configuration parameters for a new client.
4052type Config struct {
0 commit comments