1

我正在学习 REST 并且对它有一些了解。

我知道有超过 4 种 http 方法:PUT、GET、POST、DELETE、HEAD、OPTIONS、CONNECT。参考:http ://www.w3schools.com/tags/ref_httpmethods.asp

我已经安装了邮递员插件,发现还有其他方法,比如:COPY、LINK、UNLINK、PURGE。参考:https ://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en

如果这些也是http方法,有人可以给我一个参考网址来浏览这些文档吗?

来到我的实际问题:RESTful Web 服务是否应该仅使用 PUT、GET、POST 和 DELETE 构建,因为 Internet 上的许多网站仅使用这 4 种 HTTP 方法来解释 REST?

4

2 回答 2

2

Short answer: no. But, first, take Julian Reschke's advice into account: the RFC 2616 is dead. Take a look at these articles:

Of course you can use other methods. For example, there is the PATCH method and you should use it for partial updates. According to the RFC5789, the PUT method shouldn't make partial updates.

The PUT method is already defined to overwrite a resource with a complete new body, and cannot be reused to do partial changes. (http://www.ietf.org/rfc/rfc5789.txt).

It depends on the method semantics and if these semantics apply to your REST Service. One more example: suppose a client of your RESTful Service wants to request the metadata related to a resource instead of its representation (the data itself). How can you do that? In this case, you can use the HEAD method to present only the metadata associated to this resource (its fields/attributes, for example).

Updating the answer to include the link to the RFC 7231. Follow this link if you want to learn more about HTTP Methods and their semantics.

于 2014-11-14T14:14:48.393 回答
0

a) 不要看 RFC 2616。它已经过时了。

b) 已注册的 HTTP 方法列表在此处:http ://www.iana.org/assignments/http-methods/http-methods.xhtml (带有指向规范的指针)

于 2014-11-13T19:19:54.873 回答