gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit ab03318b7a0d48e05893f5e740b0672fc08e8a8a
parent b326bf45a9cc05175c5cdc828db00ed241ba1103
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date:   Mon, 18 Jul 2022 11:25:26 +0200

[chore] move dialer inside new (#715)

* move dialer inside new, use default resolver

* instantiate resolver
Diffstat:
Minternal/httpclient/client.go | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/internal/httpclient/client.go b/internal/httpclient/client.go @@ -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.