-
-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content-type header for application/json should not contain charset field, according do RFC 8259 #2154
Comments
Is there any update on this issue? I'd like to try creating a PR for this. |
See #2603 (comment). Thanks for @mpark86' pull request anyway. And if you don't like it, you can replace it easily by configuring |
@chinesedfan just Ctrl+F the RFC referenced in that comment and in this issue.
|
@OJezu I am not sure I get what you means. I guess you are proving your point. According to RFC 8259, the charset is not required and some servers are not supported to parse it. Never mind, at least MDN includes the charset. More servers work well with it. And as I said, if you don't like it, you can replace it easily by configuring |
@chinesedfan what I'm proving, is that application/json type does not have "charset" defined. Providing it is non-standard, no matter what the servers do with it. Axios is behaving in a way not specified in standard, and this is what the issue is about. Common errors alone in other software are not a reason to break RFC. |
@OJezu After read more carefully, I think they are 2 things.
|
@chinesedfan where in RFC7231 is charset parameter defined for application/json? It's not, because parameter names are defined for concrete media-types in appropriate RFCs. From RFC7231
See IANA media type registry for And compare to |
@OJezu I see. Now you have persuaded me. |
Any progress on that? |
There was a pull request done #2603, but @mpark86 did not change the expected header in tests, so they are failing. Until somebody fixes tests I expect no progress. I switched to node-fetch, so I lost interest anyway. If you can't switch out, tough luck, I suggest fixing the PR and hoping someone will merge and release. |
We should try mend this in 0.20.0 I will look at the pull request. |
In axios release v0.21.2 they have [removed the charset field from application/json Content-type header](axios/axios#2154) which UAA api doesn't like so paas-admin password reset requests have been 404ing for users. This adds the charset back so all is good now.
axios v0.21.2 [removes the charset from JSON Content-Type headers](axios/axios#2154). This adjusts the tests to compensate for that change.
* chore(deps-dev): bump axios from 0.21.1 to 0.24.0 Bumps [axios](https://github.com/axios/axios) from 0.21.1 to 0.24.0. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) - [Commits](axios/axios@v0.21.1...v0.24.0) --- updated-dependencies: - dependency-name: axios dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: remove charset from tests axios v0.21.2 [removes the charset from JSON Content-Type headers](axios/axios#2154). This adjusts the tests to compensate for that change. * test: change axios mocking use 'axios-mock-adapter' over 'moxios' due to library changes that cause incompatibilites with new versions of axios (over 0.21). * build: update axios to 0.24 * fix: upgrade to axios 0.25.0 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Bourne <jamesmbourne@users.noreply.github.com> Co-authored-by: James Bourne <jamesbourne@outlook.com>
Describe the bug
According to RFC 8259 - The JavaScript Object Notation (JSON) Data Interchange Format content-type
application/json
does not have any charset defined, as it must be utf-8 encoded. Older specifications allowed other unicode encodings, and parsers were detecting exact encoding used by first four bytes, still not by charset param.Axios defaults to header
Content-Type: application/json;charset=utf-8
for some types of sent data.This breaks some HTTP servers and applications, who are not recognizing the content-type.
To Reproduce
Expected behavior
Content-Type: application/json
header should be set as default for object data, without charset parameter.Environment:
axios/lib/defaults.js
Line 52 in b4c5d35
Additional context/Screenshots
This breaks some parts of the rabbitmq-management API.
Related issues:
#859
The text was updated successfully, but these errors were encountered: