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

前端 未结 2 1589
时光说笑
时光说笑 2021-02-05 07:07

Is there any effective difference between

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

?

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 07:59

    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.

提交回复
热议问题