agent: Fixing multiple headers for /v1/event/list endpoint. Fixes #361

This commit is contained in:
Armon Dadgar 2014-10-13 17:53:54 -07:00
parent 3e32e906d1
commit 84649b5423
3 changed files with 8 additions and 3 deletions

View File

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

View File

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

View File

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