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":
|
case "POST":
|
||||||
ctype := r.Header.Get("Content-Type")
|
ctype := r.Header.Get("Content-Type")
|
||||||
if ctype != "application/json" {
|
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
|
return
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
b, err := ioutil.ReadAll(r.Body)
|
||||||
|
@ -717,6 +717,7 @@ func TestServeAdminMembersFail(t *testing.T) {
|
|||||||
URL: mustNewURL(t, adminMembersPrefix),
|
URL: mustNewURL(t, adminMembersPrefix),
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Body: ioutil.NopCloser(strings.NewReader("bad json")),
|
Body: ioutil.NopCloser(strings.NewReader("bad json")),
|
||||||
|
Header: map[string][]string{"Content-Type": []string{"application/json"}},
|
||||||
},
|
},
|
||||||
&resServer{},
|
&resServer{},
|
||||||
|
|
||||||
@ -732,7 +733,7 @@ func TestServeAdminMembersFail(t *testing.T) {
|
|||||||
},
|
},
|
||||||
&errServer{},
|
&errServer{},
|
||||||
|
|
||||||
http.StatusBadRequest,
|
http.StatusUnsupportedMediaType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// bad url
|
// bad url
|
||||||
|
Loading…
x
Reference in New Issue
Block a user