Skip to content

Should JSONResponse add "charset=utf-8" to "Content-Type" header? #1791

Discussion options

You must be logged in to vote

The encoding content type parameter is defined only for text MIME subtypes, but the standard JSON media type is an application subtype, application/json:

  • RFC 2046 defines charset as part of the specification for the text type;
  • RFC 2616 sets the default of iso-8859-1 only for text subtypes (emphasis mine):

    When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP.

  • RFC 9110, that supersedes RFC 2616, says (emphasis mine):

    HTTP uses "charset" names to indicate or negotiate the character encoding scheme ([RFC6365], Section 2) of a textual representation.

  • RFC 4627, th…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@sashkent3
Comment options

@jhominal
Comment options

@sashkent3
Comment options

@jhominal
Comment options

Answer selected by sashkent3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants