Ran into an issue making requests to a server I don't control (Microsoft ASP.NET) where it was giving me errors POSTing JSON with HTTP.post(path, json: {whatever}).
This header works: Content-Type: application/json; charset=utf-8
This did not: Content-Type: application/json; charset=UTF-8
HTTP.rb uses Ruby String#encoding.name, which returns "UTF" in all caps, which is causing the charset=UTF-8.
Ran into an issue making requests to a server I don't control (Microsoft ASP.NET) where it was giving me errors POSTing JSON with
HTTP.post(path, json: {whatever})
.This header works:
Content-Type: application/json; charset=utf-8
This did not:Content-Type: application/json; charset=UTF-8
HTTP.rb uses Ruby
String#encoding.name
, which returns "UTF" in all caps, which is causing thecharset=UTF-8
.MDN says "Case insensitive, lowercase preferred", so I just downcased the encoding name, and added a test.