agent: Fixing multiple headers for /v1/event/list endpoint. Fixes #361
This commit is contained in:
parent
f11396efaf
commit
8ee22d7fc4
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue