diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-02-06 16:58:22 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-02-19 14:15:07 +0100 |
| commit | 500da173d8a3cd2da819353f80eef6ae7ab8ecb0 (patch) | |
| tree | 0d1fa2f420b328f7f1727cc56222062603ca617d /internal/http | |
| parent | 19dac4d96820993273537f6595743d703cc77c11 (diff) | |
HTTP: Make NewClient accept an underlying http client
if the argument is nil, a fresh one is automatically created
Diffstat (limited to 'internal/http')
| -rw-r--r-- | internal/http/http.go | 7 |
1 files changed, 5 insertions, 2 deletions
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 |
