Sea*_*ere 17 encoding http utf-8 http-headers
是否有任何有效的区别
Content-Encoding: UTF-8
Content-Type: text/html; charset=utf-8
Run Code Online (Sandbox Code Playgroud)
?
Tad*_*ski 17
可选参数charset
仅对基于文本的内容有意义(Content-Types
例如text/plain
,text/html
等等).并非所有消息都是文本.
Content-Encoding
意味着整个身体已经以某种方式编码(通常是压缩的).此标头的典型值为gzip
和deflate
.此消息的接收者应解码(例如,ungzip)正文以获取原始消息.
我甚至不确定是否UTF-8
有任何意义作为一个值Content-Encoding
.
nwe*_*hof 10
根据RFC 7231 - 超文本传输协议(HTTP/1.1):语义和内容,Content-Encoding
报头包含内容编码值的列表.引用RFC:
内容编码值指示已经或可以应用于表示的编码变换.内容编码主要用于允许表示被压缩或以其他方式有用地转换而不会丢失其底层媒体类型的身份并且不丢失信息.通常,表示以编码形式存储,直接传输,并且仅由最终接收者解码.
Run Code Online (Sandbox Code Playgroud)content-coding = token
所有内容编码值都不区分大小写,应该在"HTTP内容编码注册表"中注册,如第8.4节中所定义.它们用于Accept-Encoding(第5.3.4节)和Content-Encoding(第3.1.2.2节)头字段.
第8.4节说:
"HTTP内容编码注册表"定义内容编码名称的名称空间([RFC7230]的第4.2节).内容编码注册表保存在http://www.iana.org/assignments/http-parameters.
注册表目前列出:
br Brotli Compressed Data Format [RFC7932]
compress UNIX "compress" data format [RFC7230] Section 4.2.1
deflate "deflate" compressed data ([RFC1951]) [RFC7230] Section 4.2.2
inside the "zlib" data format ([RFC1950])
exi W3C Efficient XML Interchange
gzip GZIP file format [RFC1952] [RFC7230] Section 4.2.3
identity Reserved (synonym for "no encoding" in [RFC7231] Section 5.3.4
Accept-Encoding)
pack200-gzip Network Transfer Format for Java Archives
x-compress Deprecated (alias for compress) [RFC7230] Section 4.2.1
x-gzip Deprecated (alias for gzip) [RFC7230] Section 4.2.3
Run Code Online (Sandbox Code Playgroud)
UTF-8是一种字符编码方案,不能用于无损地转换任意二进制数据(至少不会以任何有意义的方式).设置Content-Encoding
为完全错误UTF-8
.用户代理可能只是忽略未知值或丢弃该消息并报告错误.设置字符编码方案的正确位置是Content-Type
标题.