知识卡片

普通读书笔记卡 · 3484

载荷与内容类型共同传数据

理解等级:初级

HTTP 消息体承载请求或响应交换的数据,JSON、XML 等媒体类型决定如何解释这些字节;Content-Type 首部告知对方编码类型。请求有方法、URL、首部和可选消息体,响应有状态码、首部和可选消息体,因此不能仅凭 URL 推断数据格式。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 4 章《Principles of REST API design》(源文件:_epub-src/OEBPS/Text/04.htm) - 结论依据:原文定义 HTTP 请求与响应的组成,并明确消息体可按 XML/JSON 等媒体类型编码,Content-Type 标明类型。 - 原始内容:An HTTP message body or payload is a message that contains the data exchanged in an HTTP request. Both HTTP requests and responses can contain a message body. The message body is encoded in one of the media types supported by HTTP, such as XML or JSON. The Content-Type header of the HTTP request tells us the encoding type of the message.