Skip to content

Commit

Permalink
fixbug, Content-Type validate
Browse files Browse the repository at this point in the history
OkHttp,'; charset=utf-8' append to 'application/json' by self  , but PostMan is not. So, to be compatible with these two forms (application/json, application/json; charset=utf-8) to strings.Contains
  • Loading branch information
worker24h committed May 11, 2024
1 parent c773028 commit c765900
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/http_endpoint/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (v *apiValidator) validateRequest(r *http.Request) (status int, err error)
return http.StatusMethodNotAllowed, fmt.Errorf("only %v requests are allowed", v.method)
}

if v.contentType != "" && r.Header.Get("Content-Type") != v.contentType {
if v.contentType != "" && !strings.Contains(r.Header.Get("Content-Type"), v.contentType) {
return http.StatusUnsupportedMediaType, fmt.Errorf("wrong Content-Type header, expecting %v", v.contentType)
}

Expand Down

0 comments on commit c765900

Please sign in to comment.