9 / 9
vs
安全性不同幂等性不同
- GET is safe, POST is not safe.
- GET is idempotent, POST is not idempotent.
- GET does not take a body, POST takes a body.
功能说明
HTTP 方法参考是九个 HTTP 请求方法(RFC 9110)的快速查阅表。每个方法都展示 API 设计中最关键的四个属性 —— safe(安全)、idempotent(幂等)、cacheable(可缓存)和是否携带 body —— 以及清晰的英文描述和典型用途。支持搜索、按属性过滤、点击方法查看完整条目,并可比对任意两个方法,确切查看它们语义上的差异。
使用方法
- 按方法名或含义搜索(例如
patch、partial)。 - 切换 Safe / Idempotent / Cacheable 过滤器以缩小列表。
- 点击某个方法阅读其完整描述和典型用例。
- 使用 Compare two methods(例如 PUT vs PATCH)查看语义差异。
示例
GET
Safe, idempotent, cacheable; retrieves a resource without changing it.
PUT vs. PATCH
Both modify a resource, but only PUT is idempotent (PATCH can have different effects when repeated).
POST vs. PUT
POST creates under a collection (server picks the URL, not idempotent); PUT puts a resource at a known URL (idempotent).
补充说明
- Safe 与 idempotent 的区别: safe 意为「不改变服务器状态」;idempotent 意为「重复调用与调用一次效果相同」。所有 safe 方法都是幂等的,反之不成立(PUT 和 DELETE 幂等但不安全)。
- 来源: 属性标志遵循 RFC 9110 / RFC 9111 和 MDN 参考。按规范
POST标记为可缓存,但缓存很少在无显式指令时存储 POST 响应。 - 相关工具: HTTP Status Codes、JSON Formatter、URL Encoder。