- transport, ok := http.DefaultTransport.(*http.Transport)
- if ok {
- copy := *transport
- transport = ©
- } else {
- // Evidently the application has replaced
- // http.DefaultTransport with a different type, so we
- // need to build our own from scratch using the Go 1.8
- // defaults.
- transport = &http.Transport{
+ c := &http.Client{
+ Timeout: requestTimeout,
+ // It's not safe to copy *http.DefaultTransport
+ // because it has a mutex (which might be locked)
+ // protecting a private map (which might not be nil).
+ // So we build our own, using the Go 1.10 default
+ // values, ignoring any changes the application has
+ // made to http.DefaultTransport.
+ Transport: &http.Transport{
+ DialContext: (&net.Dialer{
+ Timeout: connectTimeout,
+ KeepAlive: keepAlive,
+ DualStack: true,
+ }).DialContext,