From ab03318b7a0d48e05893f5e740b0672fc08e8a8a Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:25:26 +0200 Subject: [PATCH] [chore] move dialer inside new (#715) * move dialer inside new, use default resolver * instantiate resolver --- internal/httpclient/client.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/httpclient/client.go b/internal/httpclient/client.go index 55b98bbb6..56992b915 100644 --- a/internal/httpclient/client.go +++ b/internal/httpclient/client.go @@ -37,13 +37,6 @@ // 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.