Merge pull request #6436 from LiamHaworth/bugfix/6433-support-for-charset-in-content-type-header
etcdserver, api, v2http, client: Added support for semicolonsrelease-3.1
commit
b3a083d336
|
@ -761,6 +761,10 @@ func trimErrorPrefix(err error, prefix string) error {
|
||||||
|
|
||||||
func unmarshalRequest(r *http.Request, req json.Unmarshaler, w http.ResponseWriter) bool {
|
func unmarshalRequest(r *http.Request, req json.Unmarshaler, w http.ResponseWriter) bool {
|
||||||
ctype := r.Header.Get("Content-Type")
|
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" {
|
if ctype != "application/json" {
|
||||||
writeError(w, r, httptypes.NewHTTPError(http.StatusUnsupportedMediaType, fmt.Sprintf("Bad Content-Type %s, accept application/json", ctype)))
|
writeError(w, r, httptypes.NewHTTPError(http.StatusUnsupportedMediaType, fmt.Sprintf("Bad Content-Type %s, accept application/json", ctype)))
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue