Skip to content

Commit

Permalink
Update the content-type to be correct.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidtw committed Feb 22, 2019
1 parent 2a117f4 commit 194102d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/caduceus/outboundSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,18 @@ func (obs *CaduceusOutboundSender) send(secret, acceptType string, msg *wrp.Mess
payload := msg.Payload
var payloadReader *bytes.Reader

if acceptType == "wrp" {
// Use the internal content type unless the accept type is wrp
contentType := msg.ContentType
switch acceptType {
case "wrp", "application/msgpack", "application/wrp":
// WTS - We should pass the original, raw WRP event instead of
// re-encoding it.
contentType = "application/msgpack"
buffer := bytes.NewBuffer([]byte{})
encoder := wrp.NewEncoder(buffer, wrp.Msgpack)
encoder.Encode(msg)
payloadReader = bytes.NewReader(buffer.Bytes())
} else {
default:
payloadReader = bytes.NewReader(payload)
}

Expand All @@ -483,7 +487,7 @@ func (obs *CaduceusOutboundSender) send(secret, acceptType string, msg *wrp.Mess
return
}

req.Header.Set("Content-Type", msg.ContentType)
req.Header.Set("Content-Type", contentType)

// Add x-Midt-* headers
wrphttp.AddMessageHeaders(req.Header, msg)
Expand Down

0 comments on commit 194102d

Please sign in to comment.