Skip to content

Commit

Permalink
Merge pull request #814 from unihorn/91
Browse files Browse the repository at this point in the history
fix(server/v2): set correct content-type for etcdError response
  • Loading branch information
yichengq committed Jun 2, 2014
2 parents f007cf3 + db4c5e0 commit d5bfca9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
3 changes: 3 additions & 0 deletions server/v2/tests/get_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand Down

0 comments on commit d5bfca9

Please sign in to comment.