mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdhttp: 415 when content-type not JSON
This commit is contained in:
parent
d1fb732e63
commit
c07b9ae32e
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user