|
|
|
|
|
by ratsbane
6298 days ago
|
|
REST simplifies web applications because it works with the behavior built into the different levels of the web infrastructure. Browsers pop up a dialog box if you try to go back to a page requested with a non-idempotent method (anything but GET or HEAD). Caching servers treat non-idempotent requests differently from idempotent requests, etc. Understanding what REST actually means and whether something is RESTful isn't always obvious. To me it means use the appropriate HTTP method as defined in the RFCs; use the URL, including query string, as the sole resource descriptor; use the request body only to contain new information. I get a bit tripped up over what I understand to be Roy Fielding's objections to maintaining state through cookies - I continue to do that, but with a vague feeling of unease that I'm missing something. |
|
For instance if you have a shopping cart you can have "items in cart" in a cookie because that's pure client state. You can think of the client as a resource and, say, a "view cart" page as a representation of that resource.
If the cookie in any way tells the application how to behave, then you have sinned against the gods of REST. The most common example is probably the login redirection cookie.