git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/httpx/client.go (about) 1 package httpx 2 3 import ( 4 "net" 5 "net/http" 6 "time" 7 ) 8 9 // DefaultClient returns an HTTP client with sane defaults 10 func DefaultClient() *http.Client { 11 transport := &http.Transport{ 12 DialContext: (&net.Dialer{ 13 Timeout: 10 * time.Second, 14 KeepAlive: 60 * time.Second, 15 }).DialContext, 16 IdleConnTimeout: 90 * time.Second, 17 TLSHandshakeTimeout: 10 * time.Second, 18 ExpectContinueTimeout: 1 * time.Second, 19 } 20 21 return &http.Client{ 22 Transport: transport, 23 } 24 }