From f647569b84fc787beaed3300fd7c104139f6c0c1 Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Tue, 5 Jan 2021 15:55:38 +0000 Subject: [PATCH] Prefer http.Header over map[string]string to allow for multi-valued headers --- api/api.go | 7 +++---- api/api_test.go | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/api/api.go b/api/api.go index c237b2cc6d..e3e87a46fc 100644 --- a/api/api.go +++ b/api/api.go @@ -315,7 +315,7 @@ type Config struct { TLSConfig TLSConfig - Headers map[string]string + Header http.Header } // TLSConfig is used to generate a TLSClientConfig that's useful for talking to @@ -858,9 +858,8 @@ func (c *Client) newRequest(method, path string) *request { header: make(http.Header), } - for k, v := range c.config.Headers { - r.header.Set(k, v) - } + r.header = c.config.Header + if c.config.Datacenter != "" { r.params.Set("dc", c.config.Datacenter) } diff --git a/api/api_test.go b/api/api_test.go index 94566e6976..45ec027307 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -811,8 +811,8 @@ func TestAPI_SetWriteOptions(t *testing.T) { func TestAPI_Headers(t *testing.T) { t.Parallel() c, s := makeClientWithConfig(t, func(c *Config) { - c.Headers = map[string]string{ - "Hello": "World", + c.Header = http.Header{ + "Hello": []string{"World"}, } }, nil) defer s.Stop()