Content-Encoding 指 HTTP 头字段,用来说明响应(或请求)正文在传输前使用了哪种内容编码/压缩方式(如 gzip、br)。客户端会根据该信息对正文进行相应解码后再使用。常见于网页与 API 传输优化。
/ˈkɑːntent ɪnˈkoʊdɪŋ/
The server returned the page with Content-Encoding: gzip.
服务器返回页面时带有 Content-Encoding: gzip。
Because the API gateway added Content-Encoding: br, the client must decompress the response body before parsing the JSON.
由于 API 网关添加了 Content-Encoding: br,客户端在解析 JSON 之前必须先对响应正文进行解压。
该术语由 content(内容) + encoding(编码/编码方式) 组成。在 Web 语境中,encoding 不仅指字符编码,也常指对数据进行压缩、封装或变换的“编码方式”。“Content-Encoding”作为 HTTP 头字段名称,随着 HTTP 规范发展而固定下来,用于描述消息正文在传输层面的变换。
Content-Encoding 等 HTTP 语义)