Skip to content

Commit

Permalink
Merge pull request triggermesh#42 from triggermesh/content-type-fix
Browse files Browse the repository at this point in the history
Content-type verification fix
  • Loading branch information
tzununbekov authored Apr 21, 2022
2 parents 4cb9a5f + dfe6f7e commit bf63bce
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/converter/cloudevents/cloudevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ func (ce *CloudEvent) Request(request []byte, headers http.Header) ([]byte, map[
var body []byte
var err error

switch headers.Get("Content-Type") {
case "application/cloudevents+json":
contentType := headers.Get("Content-Type")

if strings.HasPrefix(contentType, "application/cloudevents+json") {
if body, context, err = parseStructuredCE(request); err != nil {
return nil, nil, fmt.Errorf("structured CloudEvent parse error: %w", err)
}
case "application/json":
} else if strings.HasPrefix(contentType, "application/json") {
body = request
context = parseBinaryCE(headers)
default:
} else {
return request, nil, nil
}

Expand Down

0 comments on commit bf63bce

Please sign in to comment.