Merged
requested to merge github/fork/cimadai/enable_decode_as_utf8_when_header_contains_application_json into master
Created by: cimadai
PR checklist
-
Read the contribution guidelines. -
Ran the shell script under ./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.- dart is not exists.
-
Filed the PR against the correct branch: master
,. Default:3.4.x
,4.0.x
master
. -
Copied the technical committee to review the pull request if your PR is targeting a particular programming language. - @ircecho, @swipesight, @jaumard
Description of the PR
The original processing is using response.body
to deserialize as json in api.mustache
.
However, this is decoded by latin1 if the header contains only application/json
instead of application/json; charset=utf-8
.
Because of this behavior, if the response body is encoded UTF-8 but the headers doesn't contain charset, the body will garbling.
cf: https://github.com/dart-lang/http/issues/175
Since playframework 2.6 returns Content-Type: application/json
without charset=utf-8
, I changed this parsing algolithm.