Skip to content

Commit

Permalink
Merge pull request #122 from Comcast/fix-content-type
Browse files Browse the repository at this point in the history
Update the content-type to be correct.
  • Loading branch information
schmidtw authored Feb 22, 2019
2 parents aa9f813 + 194102d commit 1334f64
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 1334f64

Please sign in to comment.