mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
Prefer http.Header over map[string]string to allow for multi-valued headers
This commit is contained in:
parent
cdc8cd7b0e
commit
f647569b84
@ -315,7 +315,7 @@ type Config struct {
|
|||||||
|
|
||||||
TLSConfig TLSConfig
|
TLSConfig TLSConfig
|
||||||
|
|
||||||
Headers map[string]string
|
Header http.Header
|
||||||
}
|
}
|
||||||
|
|
||||||
// TLSConfig is used to generate a TLSClientConfig that's useful for talking to
|
// 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),
|
header: make(http.Header),
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range c.config.Headers {
|
r.header = c.config.Header
|
||||||
r.header.Set(k, v)
|
|
||||||
}
|
|
||||||
if c.config.Datacenter != "" {
|
if c.config.Datacenter != "" {
|
||||||
r.params.Set("dc", c.config.Datacenter)
|
r.params.Set("dc", c.config.Datacenter)
|
||||||
}
|
}
|
||||||
|
@ -811,8 +811,8 @@ func TestAPI_SetWriteOptions(t *testing.T) {
|
|||||||
func TestAPI_Headers(t *testing.T) {
|
func TestAPI_Headers(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c, s := makeClientWithConfig(t, func(c *Config) {
|
c, s := makeClientWithConfig(t, func(c *Config) {
|
||||||
c.Headers = map[string]string{
|
c.Header = http.Header{
|
||||||
"Hello": "World",
|
"Hello": []string{"World"},
|
||||||
}
|
}
|
||||||
}, nil)
|
}, nil)
|
||||||
defer s.Stop()
|
defer s.Stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user