PATCH Method for HTTP
tools.ietf.org
tools.ietf.org
1) Commit a set of changes together as a single transaction
2) Commit a set of changes in a single HTTP request (latency matters)
And yes, you can just PUT the whole thing, unless one of the properties you aren't updating is a 4MB image, or 500MB video.I'm working with a REST framework where the authors have been forced to use a custom verb (MERGE) to provide this functionality. See http://www.odata.org/developers/protocols/operations
Imagine an item for sale that has 100KB of text as a description. Does it really make sense to link to the description text rather than keep it along with the name, price, etc?
Does it make sense to update it every time from say, a mobile client?
I could also see implementing a server that accepts PUT with a diff format and just apply that patch instead of replacing the document.
Some of it seems well thought out but there are other bits that smell a bit fishy to me
> For example, if the patch document size is larger than the size of the new resource data that would be used in a PUT, then it might make sense to use PUT instead of PATCH.
The body of a PUT request is intended to specify a new representation for the resource, but there's nothing in the standards that say that the format of the PUT body has to match the final resource. Gzipping, compressing, and chunking the representation as it travels back and forth are explicitly supported, so why not PUT a representation that represents the differences between the old and new version of the resource?
Why add another one that browser makers won't implement?
PATCH is just, well, a patch—;)—to get back to the original semantics of POST, since with people using POST the way they currently do, those semantics (for things like caching) are unreliable.
PUT is also defined such that the body contains the whole resource, ideally in a Content-Encoding that you can GET with an appropriate Accept header.
The Transfer-Encoding:diff+If-Match combo is in effect the same thing as sending the whole data blob, it's just an efficient transfer compression. No different than Transfer-Encoding:gzip; the data sent isn't the data to be stored until its Transfer-Encoding has been reversed.