てきとうなメモ

本の感想とか技術メモとか

body付きHTTP DELETE

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

  • 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)

仕様としては否定していないっぽいな。ただ、サーバの実装側で無視していたりクライアントで想定していなかったりするので、Web API仕様を決める時に利用すべきではないか。

テストとかで叩きたい場合はcURL

$ curl http://www.example.com/some/resource/id -X DELETE -d "foo=bar&hoge=fuga"

という形で叩けば良い