[英]Why is not a good practice to have an entity body in a HTTP DELETE request?
I am working with Restful Web Services using Java and JAX-RS and I came across the issue of sending a DELETE
request with an entity body. 我正在使用Java和JAX-RS使用Restful Web Services ,并且遇到了使用实体正文发送DELETE
请求的问题。
I spent a couple of hours looking for a way to send a DELETE
request with a message in the body but the only thing that I found was a work around using the Apache HttpClient . 我花了几个小时来寻找一种发送带有正文中消息的DELETE
请求的方法,但是我发现的唯一发现就是使用Apache HttpClient的工作 。
Some of the answers I found are saying that it does not make sense to have a body in DELETE
requests and as I see it many servers are supporting this by not allowing a DELETE
with body. 我发现的一些答案是说,在DELETE
请求中包含主体是没有意义的,而且正如我所见,许多服务器通过不允许使用body进行DELETE
来支持这一点。 eg " entity enclosing DELETE requests make no sense " 例如:“ 包含DELETE请求的实体没有意义 ”
So my question is why it is not a good practice to have a body in a DELETE
request? 所以我的问题是,为什么在DELETE
请求中包含主体不是一种好习惯? What is the drawback on this? 这有什么缺点?
Thanks 谢谢
The DELETE method requests that the origin server delete the resource identified by the Request-URI. DELETE方法请求原始服务器删除由Request-URI标识的资源。 and every resource on web server is identified by only URI. 并且Web服务器上的每个资源仅由URI标识。 thats why it does not make sense to have body in DELETE 多数民众赞成在为什么删除身体没有意义
REST is noisy, and it is likely that a separate DELETE call for each resource was the intent. REST嘈杂,很可能是针对每个资源的单独DELETE调用。 For a limited number of ids, you could use a query param on the collection resource: 对于有限数量的ID,可以在集合资源上使用查询参数:
DELETE /widgets?id=1,2,4,16,256
In general, you should be able to use query params as filters on a DELETE of a collection just like you would on a GET of that collection. 通常,您应该能够在集合的DELETE上使用查询参数作为过滤器,就像对该集合的GET一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.