Prefer http.Header over map[string]string to allow for multi-valued headers

This commit is contained in:
Conor Mongey
2021-01-05 15:43:24 +00:00
parent 3aadee8674
commit 679864ea05
2 changed files with 4 additions and 6 deletions

View File

@@ -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
}

View File

@@ -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()