Re: Re: the meaning of stateless
Matt McClure <[email protected]> Thu, 9 May 2013 14:27:11 -0400
| Newsgroups | gmane.comp.web.services.rest |
|---|---|
| Message-ID | <CAJELnLECkpSWb74+Rpm+dqp-3SHUD+WeCFeoCfnBESH=StGC8g@mail.gmail.com> |
On Thu, May 9, 2013 at 9:43 AM, Bob Haugen <[email protected]> wrote: > ** > > > Eric Bowman wrote: > > My nutshell explanation of REST from 50,000ft is that a system > > designed to manipulate shopping carts MUST be based on > > transferring actual representations of shopping-cart contents. > > I hesitated to get back into this issue after having lost an argument > with Mark Baker about it a couple of years ago, but: the typical > behavior of a system that saves shopping cart contents on servers > (e.g. Amazon) is to send a representation of the shopping cart > contents back to the client to confirm the order, in which case, a > representation of the shopping cart contents then gets sent back to > the server from the client. > > Would e.g. Mark and Eric agree that this is RESTful? > I've also been following this conversation as a lurker. If I understood some of the earlier comments, it sounded as though someone made a case that a request like: POST /cart/12345/purchase Content-Length: 0 would be stateful and undesirable for conformance with REST whereas: POST /purchase Content-Length: 1234 items=...&in_quantities=...&with_payment_method=... would be more RESTful and less stateful. I guess I'm unclear why the former would violate statelessness. The state in the former is resource state, identified by an implicit /cart/12345 resource (assume I got the /cart/12345/purchase link from the cart resource). To contrast: POST /purchase Content-Length: 0 Cookie: client=12345 seems decidedly stateful because it requires shared state identified by the ID in the Cookie header rather than the URI to disambiguate which thing the client wants to purchase. It seems to me that a client need not include all of the detail of the cart contents and payment method in the purchase request to conform with a statelessness constraint. I'd be happy to hear why I'm wrong if I am. Matt -- Matt McClure http://matthewlmcclure.com http://www.mapmyfitness.com/profile/matthewlmcclure