Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of Accept-charset HTTP header

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.

like image 292
Blessed Geek Avatar asked Nov 03 '11 15:11

Blessed Geek


People also ask

What is the use of accept-encoding header?

The Accept-Encoding request HTTP header indicates the content encoding (usually a compression algorithm) that the client can understand. The server uses content negotiation to select one of the proposals and informs the client of that choice with the Content-Encoding response header.

What is accept charset in form?

The accept-charset attribute is used to define the character encoding and is used for form submission. The default value of the accept-charset attribute is “UNKNOWN” string which indicates the encoding equals to the encoding of the document containing the <form> element. Syntax: <form accept-charset = "character_set">

Is HTTP Accept header required?

It's up to you to decide whether you want to reject requests with Accept headers or not.

What is the use of Content-Type and accept header properties?

Accept header is used by HTTP clients to tell the server which type of content they expect/prefer as response. Content-type can be used both by clients and servers to identify the format of the data in their request (client) or response (server) and, therefore, help the other part interpret correctly the information.


1 Answers

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.
like image 117
npcode Avatar answered Oct 05 '22 13:10

npcode