From 5cfa9e23849521eb29ef326b3e8d0351db44b124 Mon Sep 17 00:00:00 2001 From: Liam Haworth Date: Thu, 15 Sep 2016 12:25:20 +1000 Subject: [PATCH] etcdserver, api, v2http, client: Added support for semicolons Added support into the v2 API to fix an issue (6433) where if there is a semicolon and fields after it the API would return an "invalid Content-type" message even if the content type was actually correct --- etcdserver/api/v2http/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etcdserver/api/v2http/client.go b/etcdserver/api/v2http/client.go index f98f5752d..03ca64002 100644 --- a/etcdserver/api/v2http/client.go +++ b/etcdserver/api/v2http/client.go @@ -761,6 +761,10 @@ func trimErrorPrefix(err error, prefix string) error { func unmarshalRequest(r *http.Request, req json.Unmarshaler, w http.ResponseWriter) bool { ctype := r.Header.Get("Content-Type") + semicolonPosition := strings.Index(ctype, ";") + if semicolonPosition != -1 { + ctype = strings.TrimSpace(strings.ToLower(ctype[0:semicolonPosition])) + } if ctype != "application/json" { writeError(w, r, httptypes.NewHTTPError(http.StatusUnsupportedMediaType, fmt.Sprintf("Bad Content-Type %s, accept application/json", ctype))) return false