Rails default charset for request body

532 views Asked by At

I've built an API endpoint with rails that accepts an XML payload in the request body. The XML has UTF8 characters in it but the client making the request didn't specify the charset in their Content-Type header so my controller is treating the string as an ACII 8-bit encoded string and it's causing problems in certain codepaths.

I'm unable to tell the client to set the charset to utf8 in their request because they have a legacy system and it's too much work for them to change. Is there a way I can tell my controllers or action dispatch to treat the request body as utf8 when no charset is provided in the Content-Type header so that codepaths that are deeper in the stack don't have to care about character encoding and just assume they'll always be handling UTF8 strings?

0

There are 0 answers