mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdhttp: add Content-Type: application/json header to version handler
This commit is contained in:
parent
c9be719d92
commit
1226838381
@ -381,6 +381,7 @@ func serveVersion(w http.ResponseWriter, r *http.Request, clusterV string) {
|
|||||||
Cluster: clusterV,
|
Cluster: clusterV,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
b, err := json.Marshal(&vs)
|
b, err := json.Marshal(&vs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
plog.Panicf("cannot marshal versions to json (%v)", err)
|
plog.Panicf("cannot marshal versions to json (%v)", err)
|
||||||
|
@ -1341,6 +1341,9 @@ func TestServeVersion(t *testing.T) {
|
|||||||
if g := rw.Body.String(); g != string(w) {
|
if g := rw.Body.String(); g != string(w) {
|
||||||
t.Fatalf("body = %q, want %q", 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) {
|
func TestServeVersionFails(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user