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
9ee3ed777b
commit
f8b98d3925
@ -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)
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user