Use of Accept-charset HTTP header

Blessed Geek picture Blessed Geek · Nov 3, 2011 · Viewed 7.8k times · Source

What are the differences and advantages of using one over the other:

Accept: application/json;charset=utf-8

versus:

Accept: application/json
Accept-Charset: utf-8

Is the first form compliant to rfc 2616?

Note: could be json or xml, etc.

Answer

npcode picture npcode · Oct 27, 2013

Both of them are compliant. But I prefer second one.

"charset" parameter is for media type and media types are defined by IANA, not by RFC 2616.

  • Even if the server understands RFC 2616, you cannot be sure it understands "charset" parameter.
  • Some media types may not have "charset" parameter.