diff --git a/pkg/proxy/engines/key.go b/pkg/proxy/engines/key.go index e627f7c0d..dbac3fb07 100644 --- a/pkg/proxy/engines/key.go +++ b/pkg/proxy/engines/key.go @@ -95,12 +95,12 @@ func (pr *proxyRequest) DeriveCacheKey(extra string) string { } if methods.HasBody(r.Method) && pc.CacheKeyFormFields != nil && len(pc.CacheKeyFormFields) > 0 { - ct := r.Header.Get(headers.NameContentType) + ct := strings.ToLower(r.Header.Get(headers.NameContentType)) if ct == headers.ValueXFormURLEncoded || - strings.HasPrefix(ct, headers.ValueMultipartFormData) || ct == headers.ValueApplicationJSON { + strings.HasPrefix(ct, headers.ValueMultipartFormData) || strings.HasPrefix(ct, headers.ValueApplicationJSON) { if strings.HasPrefix(ct, headers.ValueMultipartFormData) { pr.ParseMultipartForm(1024 * 1024) - } else if ct == headers.ValueApplicationJSON { + } else if strings.HasPrefix(ct, headers.ValueApplicationJSON) { var document map[string]interface{} err := json.Unmarshal(b, &document) if err == nil { diff --git a/pkg/proxy/params/params.go b/pkg/proxy/params/params.go index 7f831da55..dcdb1f122 100644 --- a/pkg/proxy/params/params.go +++ b/pkg/proxy/params/params.go @@ -97,6 +97,10 @@ func GetRequestValues(r *http.Request) (url.Values, string, bool) { r.Body.Close() r.Body = io.NopCloser(bytes.NewReader(b)) s = string(b) + isBody = true + if strings.HasPrefix(strings.ToLower(r.Header.Get(headers.NameContentType)), headers.ValueApplicationJSON) { + return v, s, isBody + } if vs, err := url.ParseQuery(s); err == nil && isQueryBody(r) { for vsk := range vs { for _, vsv := range vs[vsk] { @@ -108,7 +112,6 @@ func GetRequestValues(r *http.Request) (url.Values, string, bool) { } } } - isBody = true } return v, s, isBody }