Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Content-Type...charset=X and Content-Encoding=X?

Tags:

Is there any effective difference between

Content-Encoding: UTF-8 Content-Type: text/html; charset=utf-8 

?

like image 681
Seamus Abshere Avatar asked May 09 '11 14:05

Seamus Abshere


People also ask

What is content encoding?

Content encoding is mainly used to compress the message data without losing information about the origin media type. Note that the original media/content type is specified in the Content-Type header, and that the Content-Encoding applies to the representation, or "coded form", of the data.

What is the meaning of content type application JSON charset UTF 8?

Content-type: application/json; charset=utf-8 designates the content to be in JSON format, encoded in the UTF-8 character encoding. Designating the encoding is somewhat redundant for JSON, since the default (only?) encoding for JSON is UTF-8.

What is the purpose of accept-encoding?

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 Br encoding?

Brotli is a lossless data compression algorithm developed by Google. It uses a combination of the general-purpose LZ77 lossless compression algorithm, Huffman coding and 2nd order context modelling. Brotli.


1 Answers

Optional parameter charset makes sense only for text-based content (Content-Types like text/plain, text/html, and such). Not all messages are text.

Content-Encoding means that the whole body has been encoded in some way (usually compressed). Typical values for this header are gzip and deflate. The recipient of this message should decode (e.g. ungzip) the body to get the original message.

I'm not even sure if UTF-8 makes any sense as a value for the Content-Encoding.

like image 162
Tadeusz A. Kadłubowski Avatar answered Sep 21 '22 01:09

Tadeusz A. Kadłubowski