Short version of the question:
Does "GET" at a particular URI need to match what was "PUT" to that URI?
I think not. Here s why:
Given that a resource is an abstract thing that is theoretically unknowable by the client, when we do a PUT, we must be only sending a representation. Based on combing over RFC2616, it doesn t seem entirely specified as to what that means for a resource that has many (potentially infinite?) representations, but here are my thoughts; please tell me if you agree:
My expectation is that if I PUT a representation to a resource, all other representations of the resource at that URI should be kept consistent (potentially updated) as necessary. In other words, you re telling the resource "use this representation to redefine yourself".
Thus, I should be able to do this:
PUT /resources/foo/myvacation
Content-type: image/jpg
...
And follow up with this:
GET /resources/foo/myvacation
Accept: image/png
...
and get the updated version of myvacation in a different format (assuming the server knows how to do that). Extrapolating from that, this composite atomic "image + metadata" PUT should also be legal:
PUT /resources/foo/myvacation
Content-type: multipart/form-dataContent-disposition: form-data; name="document"
Content-type: image/jpg
[..]
Content-disposition: form-data; name="iptc"
Content-type: application/iptc
[..]
Content-disposition: form-data; name="exif"
Content-type: application/exif
[..]
And then, because server-side content negotiation (RFC2616 section 12.1) can take place based on just about anything, we can default to the "document" content for this:
GET /resources/foo/myvacation
Content-type: image/jpg
[..]
or if you believe as I do that RFC 2396 section 3.4 "The query component is a string of information to be interpreted by the resource." means that a URI with a query string refers to the same resource as a URI without a query string (and is isomorphic with just sending application/x-form-urlencoded data to the resource), then this should also be legal:
GET /resources/foo/myvacation?content=exif
Content-type: application/exif
[..]
The description of PUT says:
The PUT method requests that the enclosed entity be stored under the supplied Request-URI.
To me, this is fairly anti-REST, unless you read it in a very liberal manner. My interpretation is "The PUT method requests that a resource be created or updated at the supplied Request-URI based on the representation of the enclosed entity."
Later on, we get:
The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource.
We need to similarly read this creatively, but the key bits here are "knows what URI is intended" and "apply the request".
So, to me the representation returned by GET at a given URI does not necessarily have to be the same representation that was PUT to the given URI, it just has to be consistent.
True or false?