mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #814 from unihorn/91
fix(server/v2): set correct content-type for etcdError response
This commit is contained in:
commit
d5bfca9465
@ -143,5 +143,6 @@ func (e Error) Write(w http.ResponseWriter) {
|
||||
status = http.StatusInternalServerError
|
||||
}
|
||||
}
|
||||
http.Error(w, e.toJsonString(), status)
|
||||
w.WriteHeader(status)
|
||||
fmt.Fprintln(w, e.toJsonString())
|
||||
}
|
||||
|
@ -24,12 +24,15 @@ func TestV2GetKey(t *testing.T) {
|
||||
v.Set("value", "XXX")
|
||||
fullURL := fmt.Sprintf("%s%s", s.URL(), "/v2/keys/foo/bar")
|
||||
resp, _ := tests.Get(fullURL)
|
||||
assert.Equal(t, resp.Header.Get("Content-Type"), "application/json")
|
||||
assert.Equal(t, resp.StatusCode, http.StatusNotFound)
|
||||
|
||||
resp, _ = tests.PutForm(fullURL, v)
|
||||
assert.Equal(t, resp.Header.Get("Content-Type"), "application/json")
|
||||
tests.ReadBody(resp)
|
||||
|
||||
resp, _ = tests.Get(fullURL)
|
||||
assert.Equal(t, resp.Header.Get("Content-Type"), "application/json")
|
||||
assert.Equal(t, resp.StatusCode, http.StatusOK)
|
||||
body := tests.ReadBodyJSON(resp)
|
||||
assert.Equal(t, body["action"], "get", "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user