RESTful web services and HTTP verbs

前端 未结 5 1903
后悔当初
后悔当初 2021-02-19 06:37

What is the minimum set of HTTP verbs that a server should allow for a web service to be classed as RESTful?

What if my hoster doesn\'t permit PUT

5条回答
  •  别跟我提以往
    2021-02-19 07:00

    REST allows for breaking protocol convention if the implementations of the protocol are broken (so that the only non-standard things you do are to get around the broken parts of the implementation). So it is allowable within REST to use some other method to represent generally unsupported verbs like DELETE or PUT.

    edit: Here is a quote from Fielding, who is the one that created and defined REST:

    A REST API should not contain any changes to the communication protocols aside from filling-out or fixing the details of underspecified bits of standard protocols, such as HTTP’s PATCH method or Link header field. Workarounds for broken implementations (such as those browsers stupid enough to believe that HTML defines HTTP’s method set) should be defined separately, or at least in appendices, with an expectation that the workaround will eventually be obsolete. [Failure here implies that the resource interfaces are object-specific, not generic.]

提交回复
热议问题