Bear Bibeault wrote:
Question: in such a scenario, would it be improper to return the results directly as the response to the POST?
Peer Reynders wrote:By trying to return the result immediately you are giving up some wiggle room. ... the representation isn't cache-able.
Some queries and processes can take a long time to complete.
Bear Bibeault wrote:Would it be deemed acceptable to have this a client-defined property: choose to receive direct results or a GET-able URI?
Overloading POST (p.220) wrote: ...
This is how most web applications work. XML-RPC and SOAP/WSDL web services also run over overloaded POST. I strongly discourage the use of overloaded POST, because it ruins the uniform interface. If you're tempted to expose complex objects or processes through overloaded POST, try giving objects or processes their own URIs, and exposing them as resources. I show several examples of this in "Resource Design" later in this chapter.
There are two noncontroversial uses for overloaded POST. The first is to simulate HTTP's uniform interface for clients like web browsers that don't support PUT or DELETE. The second is to work around limits of the maximum length of a URI. The HTTP standard specifies no limit on how long a URI can get, but many clients and servers impose their own limits: Apache won't respond to requests for URI's longer than 8KB. If a client can't make a GET request to http://www.example.com/numbers/11111111 because of URI length restrictions (imagine a million more ones there if you like), it can make a POST request to http://www.example.com/numbers?_method=GET and put "11111111" in the entity body.
...
A rule of thumb: if you're using POST, and never expose GET and POST on the same URI, you're probably not exposing resources at all. You've got an RPC-style service.
...
The principles of REST and the ROA are not arbitrary restrictions. They're simplifying assumptions that give advantages to resource-oriented services over the competition. RESTful resource-oriented services are simpler, easier to use, more interoperable, and easier to consume than RPC-style services.
Bear Bibeault wrote:I'm imagining clients that hem-and-haw over having to do the subsequent GET rather than just receiving the results directly in the POST response.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |