From 679864ea05c53f96474e5c394acf10f7cfc2b90c Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Tue, 5 Jan 2021 15:43:24 +0000 Subject: [PATCH] Prefer http.Header over map[string]string to allow for multi-valued headers --- api/api.go | 6 ++---- api/api_test.go | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/api/api.go b/api/api.go index f0d4022b8..0efb10bbb 100644 --- a/api/api.go +++ b/api/api.go @@ -156,7 +156,7 @@ type Config struct { // TLSConfig is ignored if HttpClient is set. TLSConfig *TLSConfig - Headers map[string]string + Headers http.Header } // ClientConfig copies the configuration with a new client address, region, and @@ -676,9 +676,7 @@ func (c *Client) newRequest(method, path string) (*request, error) { } } - for key, value := range c.config.Headers { - r.header.Set(key, value) - } + r.header = c.config.Headers return r, nil } diff --git a/api/api_test.go b/api/api_test.go index e2dcd6321..0048ecdfe 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -344,8 +344,8 @@ func TestParseWriteMeta(t *testing.T) { func TestClientHeader(t *testing.T) { t.Parallel() c, s := makeClient(t, func(c *Config) { - c.Headers = map[string]string{ - "Hello": "World", + c.Headers = http.Header{ + "Hello": []string{"World"}, } }, nil) defer s.Stop()