[chore] move dialer inside new (#715)

* move dialer inside new, use default resolver

* instantiate resolver
This commit is contained in:
tobi 2022-07-18 11:25:26 +02:00 committed by GitHub
parent b326bf45a9
commit ab03318b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,13 +37,6 @@ var ErrReservedAddr = errors.New("dial within blocked / reserved IP range")
// ErrBodyTooLarge is returned when a received response body is above predefined limit (default 40MB).
var ErrBodyTooLarge = errors.New("body size too large")
// dialer is the base net.Dialer used by all package-created http.Transports.
var dialer = &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
Resolver: &net.Resolver{Dial: nil},
}
// Config provides configuration details for setting up a new
// instance of httpclient.Client{}. Within are a subset of the
// configuration values passed to initialized http.Transport{}
@ -95,8 +88,11 @@ type Client struct {
func New(cfg Config) *Client {
var c Client
// Copy global
d := dialer
d := &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
Resolver: &net.Resolver{},
}
if cfg.MaxOpenConns <= 0 {
// By default base this value on GOMAXPROCS.