etcdhttp: 415 when content-type not JSON

release-2.0
Brian Waldon 2014-10-28 10:35:15 -07:00
parent d1fb732e63
commit c07b9ae32e
2 changed files with 3 additions and 2 deletions

View File

@ -172,7 +172,7 @@ func (h *adminMembersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
case "POST":
ctype := r.Header.Get("Content-Type")
if ctype != "application/json" {
writeError(w, httptypes.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Bad Content-Type %s, accept application/json", ctype)))
writeError(w, httptypes.NewHTTPError(http.StatusUnsupportedMediaType, fmt.Sprintf("Bad Content-Type %s, accept application/json", ctype)))
return
}
b, err := ioutil.ReadAll(r.Body)

View File

@ -717,6 +717,7 @@ func TestServeAdminMembersFail(t *testing.T) {
URL: mustNewURL(t, adminMembersPrefix),
Method: "POST",
Body: ioutil.NopCloser(strings.NewReader("bad json")),
Header: map[string][]string{"Content-Type": []string{"application/json"}},
},
&resServer{},
@ -732,7 +733,7 @@ func TestServeAdminMembersFail(t *testing.T) {
},
&errServer{},
http.StatusBadRequest,
http.StatusUnsupportedMediaType,
},
{
// bad url