application/json POST content not returned as binary data
Hi,
I have a legacy API that uses taffy and CF 2018, and I'm posting json with Content-Type: application/json to the API.
taffy checks for binary data it gets from getHTTPRequestData().content. The documentation for getHTTPRequestData says that binary data will be returned if the content type doesn't start with 'text' or if it is "application/x-www-form-urlencoded."
I have confirmed that the data are being posted with Content-Type: application/json, but getHTTPRequestData().content is returning a string. If I cfdump the string, I see the following which appears to contain a representation of the bytes:
{"Code":"\u16a0\u16c7\u16bb\u16eb\u16d2\u16e6\u16a6\u16eb\u16a0\u16b1\u16a9\u16a0\u16a2\u16b1\u16eb\u16a0","CodeID":"515","CodeDescription":"foo"}
The Code in the JSON was a test string with ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠ.
Would anyone have any ideas how data might be getting garbled before it gets to the taffy CF application.cfc (which extends the taffy.core.api cfc)?
<cffunction name="getRequestBody" access="private" output="false" hint="Gets request body data, which CF doesn't do automatically for some verbs">
<!--- Special thanks to Jason Dean (@JasonPDean) and Ray Camden (@ColdFusionJedi) who helped me figure out how to do this --->
<cfset var body = getHTTPRequestData().content />
<!--- on input with content-type "application/json" CF seems to expose it as binary data. Here we convert it back to plain text --->
<cfif isBinary(body)>
<cfset body = charsetEncode(body, "UTF-8") />
</cfif>
<cfreturn body />
