File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package http
22
33import (
4+ "context"
45 "net"
56 "net/http"
67 "time"
@@ -12,12 +13,23 @@ type httpClient interface {
1213 Do (req * http.Request ) (* http.Response , error )
1314}
1415
16+ func dialer () * net.Dialer {
17+ return & net.Dialer {
18+ Resolver : & net.Resolver {
19+ PreferGo : true ,
20+ Dial : func (ctx context.Context , network , _ string ) (net.Conn , error ) {
21+ d := net.Dialer {Timeout : 10 * time .Second }
22+ return d .DialContext (ctx , network , "8.8.8.8:53" ) // Use Google DNS
23+ },
24+ },
25+ Timeout : 30 * time .Second ,
26+ }
27+ }
28+
1529var (
1630 defaultTransport http.RoundTripper = & http.Transport {
17- Proxy : http .ProxyFromEnvironment ,
18- Dial : (& net.Dialer {
19- Timeout : 10 * time .Second ,
20- }).Dial ,
31+ Proxy : http .ProxyFromEnvironment ,
32+ Dial : dialer ().Dial ,
2133 TLSHandshakeTimeout : 10 * time .Second ,
2234 ResponseHeaderTimeout : 10 * time .Second ,
2335 }
You can’t perform that action at this time.
0 commit comments