88 "net/http"
99 "net/netip"
1010 "sync"
11- "time"
1211
1312 "github.com/database64128/ddns-go/internal/httpreq"
1413 "github.com/database64128/ddns-go/producer"
@@ -150,28 +149,10 @@ func (s *textSource) get(ctx context.Context) (netip.Addr, error) {
150149 return addr .Unmap (), nil
151150}
152151
153- func defaultHttpTransportClone () * http.Transport {
154- transport , ok := http .DefaultTransport .(* http.Transport )
155- if ! ok {
156- // http.DefaultTransport was changed by user code to some custom implementation,
157- // so here we create a best-effort approximation of the original.
158- return & http.Transport {
159- Proxy : http .ProxyFromEnvironment ,
160- // DialContext will be set by caller.
161- ForceAttemptHTTP2 : true ,
162- MaxIdleConns : 100 ,
163- IdleConnTimeout : 90 * time .Second ,
164- TLSHandshakeTimeout : 10 * time .Second ,
165- ExpectContinueTimeout : 1 * time .Second ,
166- }
167- }
168- return transport .Clone ()
169- }
170-
171152// defaultHttpClient4 returns an [*http.Client] that behaves like
172153// [http.DefaultClient] but forces connections to use IPv4 only.
173154var defaultHttpClient4 = sync .OnceValue (func () * http.Client {
174- transport := defaultHttpTransportClone ()
155+ transport := httpreq . DefaultHttpTransportClone ()
175156 transport .DialContext = func (ctx context.Context , network , addr string ) (net.Conn , error ) {
176157 switch network {
177158 case "tcp" :
@@ -188,7 +169,7 @@ var defaultHttpClient4 = sync.OnceValue(func() *http.Client {
188169// defaultHttpClient6 returns an [*http.Client] that behaves like
189170// [http.DefaultClient] but forces connections to use IPv6 only.
190171var defaultHttpClient6 = sync .OnceValue (func () * http.Client {
191- transport := defaultHttpTransportClone ()
172+ transport := httpreq . DefaultHttpTransportClone ()
192173 transport .DialContext = func (ctx context.Context , network , addr string ) (net.Conn , error ) {
193174 switch network {
194175 case "tcp" :
0 commit comments