diff --git a/CHANGELOG.md b/CHANGELOG.md index 56aea52222..748d4c854a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ BUG FIXES: * Fixing potential race in connection multiplexing * Fixing issue with Session ID and ACL ID generation. Previously, sessions and tokens could be invalidated when the leader changed. + * Fixing multiple headers for /v1/event/list endpoint [GH-361] ## 0.4.0 (September 5, 2014) diff --git a/command/agent/http.go b/command/agent/http.go index ad1a64bfd2..1954559ac5 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -222,7 +222,7 @@ func decodeBody(req *http.Request, out interface{}, cb func(interface{}) error) // setIndex is used to set the index response header func setIndex(resp http.ResponseWriter, index uint64) { - resp.Header().Add("X-Consul-Index", strconv.FormatUint(index, 10)) + resp.Header().Set("X-Consul-Index", strconv.FormatUint(index, 10)) } // setKnownLeader is used to set the known leader header @@ -231,13 +231,13 @@ func setKnownLeader(resp http.ResponseWriter, known bool) { if !known { s = "false" } - resp.Header().Add("X-Consul-KnownLeader", s) + resp.Header().Set("X-Consul-KnownLeader", s) } // setLastContact is used to set the last contact header func setLastContact(resp http.ResponseWriter, last time.Duration) { lastMsec := uint64(last / time.Millisecond) - resp.Header().Add("X-Consul-LastContact", strconv.FormatUint(lastMsec, 10)) + resp.Header().Set("X-Consul-LastContact", strconv.FormatUint(lastMsec, 10)) } // setMeta is used to set the query response meta data diff --git a/command/agent/http_test.go b/command/agent/http_test.go index 21e59b8f4d..d2ee63e7dd 100644 --- a/command/agent/http_test.go +++ b/command/agent/http_test.go @@ -47,6 +47,10 @@ func TestSetIndex(t *testing.T) { if header != "1000" { t.Fatalf("Bad: %v", header) } + setIndex(resp, 2000) + if v := resp.Header()["X-Consul-Index"]; len(v) != 1 { + t.Fatalf("bad: %#v", v) + } } func TestSetKnownLeader(t *testing.T) {