@@ -6,13 +6,12 @@ import (
66 "crypto/tls"
77 "fmt"
88 "io"
9+ "net"
910 "net/http"
1011 "net/url"
1112 "os"
1213 "strings"
1314 "time"
14-
15- "github.com/hashicorp/go-cleanhttp"
1615)
1716
1817const (
@@ -189,7 +188,7 @@ func New(username, password string, c ...ConfigFn) *Client {
189188 username : username ,
190189 password : password ,
191190 baseURL : clientBaseURL (os .Getenv (EnvDebugAPIBaseURL )),
192- httpClient : cleanhttp . DefaultClient (),
191+ httpClient : NewDefaultHTTPClient (),
193192 }
194193
195194 // If set, replace http client transport with one skipping tls verification
@@ -243,3 +242,30 @@ func handleResponse(response *http.Response) ([]byte, error) {
243242
244243 return responseBody , err
245244}
245+
246+ // NewDefaultHTTPClient returns new default http.Client.
247+ func NewDefaultHTTPClient () * http.Client {
248+ transport := NewDefaultHTTPTransport ()
249+ return & http.Client {
250+ Transport : transport ,
251+ }
252+ }
253+
254+ // NewDefaultHTTPTransport return new HTTP client transport round tripper.
255+ func NewDefaultHTTPTransport () http.RoundTripper {
256+ return & http.Transport {
257+ Proxy : http .ProxyFromEnvironment ,
258+ DialContext : (& net.Dialer {
259+ Timeout : 30 * time .Second ,
260+ KeepAlive : 30 * time .Second ,
261+ DualStack : true ,
262+ }).DialContext ,
263+ ForceAttemptHTTP2 : true ,
264+ MaxIdleConns : 100 ,
265+ IdleConnTimeout : 90 * time .Second ,
266+ TLSHandshakeTimeout : 10 * time .Second ,
267+ ExpectContinueTimeout : 1 * time .Second ,
268+ DisableKeepAlives : true ,
269+ MaxIdleConnsPerHost : - 1 ,
270+ }
271+ }
0 commit comments