简体   繁体   English

了解REST API中的HTTP DELETE方法

[英]Understanding HTTP DELETE method in a REST API

我对REST API的结构感到好奇:使用HTTP DELETE方法而不有效地删除Web服务器目录上但数据库中的资源是否正确?

The RFC 7231 defines the semantics of the HTTP DELETE method. RFC 7231定义了HTTP DELETE方法的语义。

It expresses a deletion operation on the URI mapping (and it doesn't expect that the associated content will be actually deleted from the server). 表示对URI映射的删除操作 (并且不希望实际从服务器中删除关联的内容)。 Whether the actual content will be deleted or not or whether it can be restored or not, is up to the server implementation. 实际内容是否将被删除还是可以恢复,取决于服务器的实现。

See the quote below (highlights are mine): 请参阅下面的引用(突出显示是我的):

4.3.5. 4.3.5。 DELETE 删除

The DELETE method requests that the origin server remove the association between the target resource and its current functionality. DELETE方法请求原始服务器删除目标资源与其当前功能之间的关联。 In effect, this method is similar to the rm command in UNIX: it expresses a deletion operation on the URI mapping of the origin server rather than an expectation that the previously associated information be deleted. 实际上,此方法类似于UNIX中的rm命令: 它在源服务器的URI映射上表示删除操作,而不是期望删除先前关联的信息。

If the target resource has one or more current representations, they might or might not be destroyed by the origin server, and the associated storage might or might not be reclaimed , depending entirely on the nature of the resource and its implementation by the origin server (which are beyond the scope of this specification). 如果目标资源具有一个或多个当前表示,则它们可能会或可能不会被原始服务器销毁,并且可能会或可能不会回收关联的存储 ,这完全取决于资源的性质及其由原始服务器的实现(超出了本规范的范围)。 Likewise, other implementation aspects of a resource might need to be deactivated or archived as a result of a DELETE , such as database or gateway connections. 同样, 由于DELETE (例如数据库或网关连接) 的结果,可能需要停用或归档资源的其他实现方面 In general, it is assumed that the origin server will only allow DELETE on resources for which it has a prescribed mechanism for accomplishing the deletion. 通常,假定原始服务器仅对具有预定机制以完成删除的资源允许DELETE [...] [...]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM