Browse Source

etcdhttp: 415 when content-type not JSON

Brian Waldon 11 years ago
parent
commit
c07b9ae32e
2 changed files with 3 additions and 2 deletions
  1. 1 1
      etcdserver/etcdhttp/client.go
  2. 2 1
      etcdserver/etcdhttp/client_test.go

+ 1 - 1
etcdserver/etcdhttp/client.go

@@ -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)

+ 2 - 1
etcdserver/etcdhttp/client_test.go

@@ -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