Content-Type:常见于 HTTP 和 电子邮件(MIME) 的头字段,用来说明消息正文(body)的媒体类型/数据格式,例如 text/html、application/json,并可附带参数如 charset=UTF-8。
/ˈkɑn.tent taɪp/
Set the Content-Type to application/json.
把 Content-Type 设置为 application/json。
The server returned a Content-Type of text/html; charset=UTF-8, so the browser rendered the page as HTML using UTF-8 encoding.
服务器返回的 Content-Type 是 text/html; charset=UTF-8,所以浏览器按 UTF-8 编码把页面当作 HTML 来渲染。
由 content(内容)+ type(类型) 组合而成,含义直观:用于标明“内容的类型”。该用法在互联网标准中与 MIME(Multipurpose Internet Mail Extensions,多用途互联网邮件扩展) 体系密切相关,后来被 HTTP 广泛采用来标识传输数据的格式。
Content-Type 在 HTTP 消息中的作用与规则。