Skip to content
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

Remove default charset from 'application/json' Content-Type header #2567

Closed
3 tasks done
doortts opened this issue Dec 28, 2023 · 0 comments
Closed
3 tasks done

Remove default charset from 'application/json' Content-Type header #2567

doortts opened this issue Dec 28, 2023 · 0 comments

Comments

@doortts
Copy link
Contributor

doortts commented Dec 28, 2023

Issue Description

Using application/json; charset=UTF-8 in response header is a common misuse. I think it is better to remove ; charset=UTF-8 from default json response Content-Type header to prevent the misconception.

According to the documentation at rfc8259: JSON spec, JSON has only one encoding type, 'UTF-8'. JSON must be encoded by UTF-8, and there is no "charset" parameter.

The media type for JSON text is application/json.
...
Note: No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients.

Related RFC note link

8.1. Character Encoding

JSON text exchanged between systems that are not part of a closed
ecosystem MUST be encoded using UTF-8 [RFC3629].

Related RFC 8.1 Chapter Link

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

In response header:

Content-Type: application/json

Actual behaviour

Content-Type: application/json; charset=UTF-8

Steps to reproduce

any response when to response with JSON(code int, i interface{}),
default response Content-Type header contains ; charset=UTF-8.

Version/commit

v4.11.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant