etcdhttp: add Content-Type: application/json header to version handler

This commit is contained in:
Xiang Li 2015-09-25 15:06:51 -07:00 committed by Yicheng Qin
parent 9ee3ed777b
commit f8b98d3925
2 changed files with 4 additions and 0 deletions

View File

@ -381,6 +381,7 @@ func serveVersion(w http.ResponseWriter, r *http.Request, clusterV string) {
Cluster: clusterV,
}
w.Header().Set("Content-Type", "application/json")
b, err := json.Marshal(&vs)
if err != nil {
plog.Panicf("cannot marshal versions to json (%v)", err)

View File

@ -1341,6 +1341,9 @@ func TestServeVersion(t *testing.T) {
if g := rw.Body.String(); g != string(w) {
t.Fatalf("body = %q, want %q", g, string(w))
}
if ct := rw.HeaderMap.Get("Content-Type"); ct != "application/json" {
t.Errorf("contet-type header = %s, want %s", ct, "application/json")
}
}
func TestServeVersionFails(t *testing.T) {