REST-like MOVE, COPY : "This one isn't easy."

2009-03-19 @ 18:23#

i've been doing some research lately and found a fascinating email thread discussing the way to handle MOVE and COPY over HTTP in a REST-like manner. below is one of the items in that thread; a reply by Roy T. Fielding (marked for life by his dissertation that includes the description for REST) that gives a hint as to how he might approach the problem:

[snip]I believe MOVE would simply be COPY+DELETE, aka GET+PUT+DELETE.[/snip]

Think of it another way.

The URI namespace consists of a hierarchy of names (collections). COPY and MOVE semantics are not really operations on the target of the COPY and MOVE -- in fact, they are operations on the parent collections that "own" the origin and destination namespaces. The set of names within a collection are the state of that collection as a resource. If you want to make these operations more REST-like, then define a suitable representation of a collection such that each namespace can be GET-retrieved, manipulated at the user agent, and then have the result of those manipulations communicated to the two namespaces in such a way that they can achieve the new state, barring conflicts, without unnecessary transfers across the network.

This one isn't easy.

Roy T. Fielding (2001)

not easy in deed. two things jump out at me here. first, that Fielding's approach is truly about representating state. second, this commitment to keeping REST all about communicating state (the very thing that makes the REST style so effective over widely-distributed, heterogeneous networks) makes actions such as COPY and MOVE so much harder to model.

code