知识卡片
GET请求体没有通用语义
HTTP 并未给 GET 请求体规定通用语义,因此 API 设计不能假设所有客户端、代理和服务端都会按同一方式理解它。书中提到 Elasticsearch 可接受 GET 查询体,说明特定系统能约定此用法;跨系统接口仍需把兼容性写入契约。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 4 章《Principles of REST API design》(源文件:_epub-src/OEBPS/Text/04.htm)
- 结论依据:原文说明 GET/DELETE 的消息体未被 HTTP 规范禁止,但没有定义通用语义,并以 Elasticsearch 的特定实现为例。
- 原始内容:The wording of the HTTP specification is intentionally vague on whether DELETE and GET requests can include a payload. It doesn’t forbid the use of payloads, but it states that they don’t have any defined semantics. This allows some APIs to include payloads in GET requests. A famous example is Elasticsearch, which allows clients to send query documents in the body of a GET request