From 500da173d8a3cd2da819353f80eef6ae7ab8ecb0 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 6 Feb 2024 16:58:22 +0100 Subject: HTTP: Make NewClient accept an underlying http client if the argument is nil, a fresh one is automatically created --- internal/http/http.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'internal/http') diff --git a/internal/http/http.go b/internal/http/http.go index 4d8f3bc..ba081fd 100644 --- a/internal/http/http.go +++ b/internal/http/http.go @@ -147,8 +147,11 @@ type Client struct { } // Returns a HTTP client with some default settings -func NewClient() *Client { - c := &http.Client{} +func NewClient(client *http.Client) *Client { + c := client + if c == nil { + c = &http.Client{} + } // ReadLimit denotes the maximum amount of bytes that are read in HTTP responses // This is used to prevent servers from sending huge amounts of data // A limit of 16MB, although maybe much larger than needed, ensures that we do not run into problems -- cgit v1.2.3