3 ms·
It doesn't matter: as I said, that has the same end state (no foo/bar resource), the only possible difference is response code i.e. whether (in this case) you g
by SilasX 11y ago
It doesn't matter: as I said, that has the same end state (no foo/bar resource), the only possible difference is response code i.e. whether (in this case) you get to learn that your update doesn't matter.
- marcosdumay 11y agoThe first sequence ends with foo/bar existing. The second one ends with it not existing. I'd say that anybody that sends a pair of PUT/DELETE requests in fast succession over the web and expects a stable result is a fool. This should have no effect on practice, because nobody should be relying on the ordering anyway.
- SilasX 11y agoAh, my mistake. I had always equated PUT with updating and assumed it should fail if it doesn't find the resource. Big oversight!
- rbw 11y agoI think you're correct, actually. If you want to create a new object, it should be a POST. In a well designed RESTful service, a PUT on an object that doesn't exist should fail, and both of the PUT/DELETE orderings above should result in the same state of the world: the object does not exist.
- SilasX 11y agoI thought so too, but when I looked at the spec [1], it agreed with the others: >>The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI [1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html 9.6
- rbw 11y agoSounds like the others are indeed correct. Thanks for the citation!
- thedufer 11y agoYou're probably thinking of PATCH. In many, if not most, RESTful services, PUT is given PATCH semantics. PUT is supposed to be insert-or-update.
- rbw 11y agoAh, I stand corrected. Thanks!