No, but you can use status code 428 Precondition Required (see http://greenbytes.de/tech/webdav/rfc6585.html#status-428).
Compare-and-swap for HTTP PUT?
-
16-01-2022 - |
Question
Is there a way to make a compare-and-swap-style mechanism the only way to modify certain resources, whilst following the HTTP standard?
There's an If-Match
header which implements the correct behaviour however this header is optional: as far as I can tell, if If-Match
is not provided, the server should honour the PUT
. (That is, it's up to the client to decide whether it wants to compare-and-swap, or just swap.) Would it be acceptable to respond with 412 Precondition Failed
if the client tries to PUT
or POST
without providing an If-Match
header?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow