HTTP DELETE 请求是否允许实体主体? [英] Is an entity body allowed for an HTTP DELETE request?

查看:35
本文介绍了HTTP DELETE 请求是否允许实体主体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发出 HTTP DELETE 请求时,请求 URI 应完整标识要删除的资源.但是,是否允许添加额外的元数据作为请求的实体主体的一部分?

When issuing an HTTP DELETE request, the request URI should completely identify the resource to delete. However, is it allowable to add extra meta-data as part of the entity body of the request?

推荐答案

规范 没有明确禁止或劝阻它,所以我倾向于说它是允许的.

The spec does not explicitly forbid or discourage it, so I would tend to say it is allowed.

Microsoft 以同样的方式看待它(我可以听到观众的喃喃自语),他们在 MSDN 文章中指出 ADO.NET 数据服务框架的删除方法:

Microsoft sees it the same way (I can hear murmuring in the audience), they state in the MSDN article about the DELETE Method of ADO.NET Data Services Framework:

如果 DELETE 请求包含实体主体,则主体将被忽略 [...]

If a DELETE request includes an entity body, the body is ignored [...]

另外,这里是 RFC2616 (HTTP 1.1) 必须说明的内容请求:

Additionally here is what RFC2616 (HTTP 1.1) has to say in regard to requests:

  • entity-body 仅在 message-body 存在时才存在(第 7.2 节)
  • message-body 的存在通过包含 Content-LengthTransfer-Encoding 标头(第 4.3 节)来表示
  • 当请求方法的规范不允许发送entity-body(第4.3节)时,不得包含message-body
  • entity-body 仅在 TRACE 请求中被明确禁止,所有其他请求类型不受限制(特别是第 9 节和第 9.8 节)
  • an entity-body is only present when a message-body is present (section 7.2)
  • the presence of a message-body is signaled by the inclusion of a Content-Length or Transfer-Encoding header (section 4.3)
  • a message-body must not be included when the specification of the request method does not allow sending an entity-body (section 4.3)
  • an entity-body is explicitly forbidden in TRACE requests only, all other request types are unrestricted (section 9, and 9.8 specifically)

对于响应,已定义:

  • 是否包含message-body取决于请求方法响应状态(4.3节)
  • 明确禁止在响应 HEAD 请求时使用 message-body(特别是第 9 节和第 9.4 节)
  • 在 1xx(信息性)、204(无内容)和 304(未修改)响应中明确禁止 message-body(第 4.3 节)
  • 所有其他响应都包含消息正文,但它的长度可能为零(第 4.3 节)
  • whether a message-body is included depends on both request method and response status (section 4.3)
  • a message-body is explicitly forbidden in responses to HEAD requests (section 9, and 9.4 specifically)
  • a message-body is explicitly forbidden in 1xx (informational), 204 (no content), and 304 (not modified) responses (section 4.3)
  • all other responses include a message-body, though it may be of zero length (section 4.3)

这篇关于HTTP DELETE 请求是否允许实体主体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆