httpcli: client instances do not share the same default http.Header instance
@@ -105,7 +105,7 @@ func New(opts ...Opt) *Client {
c := &Client{
codec: DefaultCodec,
do: With(DefaultConfigOpt...),
- header: DefaultHeaders,
+ header: cloneHeaders(DefaultHeaders),
errorMapper: DefaultErrorMapper,
}
c.buildRequestFunc = c.buildRequest
@@ -114,6 +114,16 @@ func New(opts ...Opt) *Client {
return c
}
+func cloneHeaders(hs http.Header) http.Header {
+ result := make(http.Header)
+ for k, v := range hs {
+ cloned := make([]string, len(v))
+ copy(cloned, v)
+ result[k] = cloned
+ }
+ return result
+}
+
// Endpoint returns the current Mesos API endpoint URL that the caller is set to invoke
func (c *Client) Endpoint() string {
return c.url
