Fixing response with utf-8 BOM can not parse to json#2419
Fixing response with utf-8 BOM can not parse to json#2419jasonsaayman merged 5 commits intoaxios:masterfrom
Conversation
|
Just saying I'd love to see this merged as I have to use an annoying workaround to use Axios with our legacy .Net services. (They all return a BOM character.) |
|
@Morgul I think you can solve it by add another |
|
@chinesedfan That works, as a work around, but I'd love to see this merged in, as axios is one of the few libraries that doesn't automatically work around this issue. 🙁 |
|
@Morgul Would you mind to list some examples? I am glad to check their implementations. And also make preparations for some users who want to keep those BOMs. |
|
@chinesedfan Here are some examples to avoid these problems. (Windows system save file with BOM, but not all HTTP services handle it) |
* add checkServerIdentity to request config for http adapter * add checkServerIdentity unit test * add checkServerIdentity doc * add more unit tests for checkServerIdentity * remove ssl-root-cas dependency * add changes description to changelog * Fixing response with utf-8 BOM can not parse to json (#2419) * fix: remove byte order marker (UTF-8 BOM) when transform response * fix: remove BOM only utf-8 * test: utf-8 BOM * fix: incorrect param name Co-authored-by: Jay <[email protected]> * Update mergeConfig.js Co-authored-by: Yasu Flores <[email protected]> Co-authored-by: Cr <[email protected]> Co-authored-by: Jay <[email protected]>
* fix: only set responseType 'json' or use defaulte responseType return JSON response * test: change defalut transform behaviour * refactor: try to parse json * fix: code style * test: response type json * fix: set default transformResponse to empty array * chore: code style * Fixing response with utf-8 BOM can not parse to json (#2419) * fix: remove byte order marker (UTF-8 BOM) when transform response * fix: remove BOM only utf-8 * test: utf-8 BOM * fix: incorrect param name Co-authored-by: Jay <[email protected]> * Update http.js * Fix trailing spaces * fix: strip Bom before parse to json Co-authored-by: Alanscut <[email protected]> Co-authored-by: Jay <[email protected]> Co-authored-by: Cr <[email protected]>
* fix: remove byte order marker (UTF-8 BOM) when transform response * fix: remove BOM only utf-8 * test: utf-8 BOM * fix: incorrect param name Co-authored-by: Jay <[email protected]>
* fix: remove byte order marker (UTF-8 BOM) when transform response * fix: remove BOM only utf-8 * test: utf-8 BOM * fix: incorrect param name Co-authored-by: Jay <[email protected]>
* add checkServerIdentity to request config for http adapter * add checkServerIdentity unit test * add checkServerIdentity doc * add more unit tests for checkServerIdentity * remove ssl-root-cas dependency * add changes description to changelog * Fixing response with utf-8 BOM can not parse to json (axios#2419) * fix: remove byte order marker (UTF-8 BOM) when transform response * fix: remove BOM only utf-8 * test: utf-8 BOM * fix: incorrect param name Co-authored-by: Jay <[email protected]> * Update mergeConfig.js Co-authored-by: Yasu Flores <[email protected]> Co-authored-by: Cr <[email protected]> Co-authored-by: Jay <[email protected]>
* fix: only set responseType 'json' or use defaulte responseType return JSON response * test: change defalut transform behaviour * refactor: try to parse json * fix: code style * test: response type json * fix: set default transformResponse to empty array * chore: code style * Fixing response with utf-8 BOM can not parse to json (axios#2419) * fix: remove byte order marker (UTF-8 BOM) when transform response * fix: remove BOM only utf-8 * test: utf-8 BOM * fix: incorrect param name Co-authored-by: Jay <[email protected]> * Update http.js * Fix trailing spaces * fix: strip Bom before parse to json Co-authored-by: Alanscut <[email protected]> Co-authored-by: Jay <[email protected]> Co-authored-by: Cr <[email protected]>
* fix: remove byte order marker (UTF-8 BOM) when transform response * fix: remove BOM only utf-8 * test: utf-8 BOM * fix: incorrect param name Co-authored-by: Jay <[email protected]>
Some services(deploy on
Windows) will response data withBOMthat can not parse it tojson.see #1768 (comment)