gpt4 book ai didi

rest - 我应该返回 410 Gone 以响应成功的 HTTP DELETE 请求吗?

转载 作者:行者123 更新时间:2023-12-04 17:22:06 24 4
gpt4 key购买 nike

我正在 ReST API 上实现 DELETE 支持(在 ServiceStack 上构建),并想知道成功删除后要返回什么响应代码。

HTTP 将 410 定义为:

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.



现在,如果一个资源刚刚被 DELETE d,我可能确实希望应用这些建议中的许多……但公认的做法似乎返回了 200 OK关注成功 DELETE - 特别是自从 4XX范围应该表示错误条件。

任何超出 HTTP 规范指南的令人信服的论点?

最佳答案

RFC 2616 Section 9.7关于 DELETE 的响应,具体说明以下内容:

A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not include an entity.

关于rest - 我应该返回 410 Gone 以响应成功的 HTTP DELETE 请求吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21025166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com