Search the web
Sign In
New User? Sign Up
rest-discuss · REST Discussion Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
REST, HTTP, Sessions and Cookies   Message List  
Reply | Forward Message #3583 of 14029 |
Re: [rest-discuss] REST, HTTP, Sessions and Cookies

> Any application of cookies breaks REST, because they are by definition
> stateful, and all REST interactions are stateless. That doesn't mean
> they don't have their uses, of course. But there other ways of doing
> "sessions" statelessly, and doing them statefully is not REST.

That concept tends to be a little confusing, partly because HTTP,
like many network protocols, has a notion of stateless interactions
that only refers to having all of the information needed to
understand each request inside the request or defined by universal
standard. REST goes further and constrains application state
(not resource state) to be held on the client. It is hard to
describe without further defining what "application" means, but
we can think of it as the context between user agent requests:
the server cannot be aware of any such context and still be REST.

This is also what allows individual pages to be bookmarked and
shared with others, but that's a longer story.

The purpose of statelessness is to prevent partial failures and
allow for substrate independence (e.g., load-balanced gateways
managing the traffic for many servers). Cookies don't
necessarily break that because they are inside the request,
unless developers make the mistake of defining the cookie such
that it varies by gateway.

Most of the problems with cookies are due to breaking visibility,
which impacts caching and the hypertext application engine, but
even worse is its use for authentication, as evidenced by the
cross-site-scripting security holes in sites that use it.
It ends up being a weird trade-off of security versus efficiency.

Using cookies is more efficient than authentication because the
server (and intermediaries) will simply ignore cookies for the
vast majority of URI (e.g., inline images). That allows everything
except the pages that set cookies to be cacheable, and those are
typically non-cacheable pages in any case. However, using cookies
in that fashion means the server is relying on security by obscurity
to associate the client's stored cookie with the application state
(attackers ability to guess the cookie or obtain it illegitimately
via XSS). Likewise, keeping state in the cookie means that the
URIs can be independent of the user state, but doing that messes-up
the client's understanding of state as presented by the hypertext
engine: it breaks the "back" button.

Unfortunately, cookies were not presented for discussion by the
community until after they had been deployed and announced as one
of Netscape's infamous "extensions". If they had, then it is more
likely that HTML would have been extended to indicate selectable
items, and browsers could then have developed a client-side
market basket that is more reliable and subject to a fancier UI.
Doing that now is simply a chicken-and-egg problem: browers won't
bother til there is user demand for the feature, and sites won't
offer it as an option until browsers implement it consistently.
Java was supposed to solve that problem, but Sun screwed that up.

Cookies that simply store a reference to server-maintained state
do violate REST's constraint on state being stored on the client,
rather than the server, for scalability. The effect of violating
that constraint can be seen on any site that uses client-sessions
on the back-end, such as is common in J2SE. Such sites are usually
several orders of magnitude less scalable than REST-based
applications, but some folks still prefer it for "personalization".
My experience has been that this is the number one cause of failed
website applications: reliance on server-side sessions.

BTW, "personalization" can be defined as deliberately trading off
scalability for customized content. The advertising folks who took
over the Web design space in 1996 claimed that this was a necessity,
often making it a core component of third-party "evaluations" of
website usability, but if you actually go and talk to the customers
using those sites you will find that they hate it with a passion.
Amazon is the only site that did it well, and it continues to cost
them a fortune in back-end costs.

....Roy




Wed Apr 16, 2003 3:36 am

roy_fielding
Offline Offline
Send Email Send Email

Forward
Message #3583 of 14029 |
Expand Messages Author Sort by Date

Following on from the recent thread which discussed modelling a multi page form submission process using REST principles, I'm wondering if there is any place...
sem_antico
Offline Send Email
Apr 10, 2003
7:51 pm

... From: "sem_antico" <rest-discuss@...> ... If one of the REST principles is visibility into messages for key information - like...
S. Mike Dierken
mdierken
Offline Send Email
Apr 12, 2003
10:01 pm

... Remember that for web services the existing model is not really broken. It's only really broken in the way browsers work and the way most marketing...
Nic Ferrier
nferrier_tap...
Offline Send Email
Apr 12, 2003
10:35 pm

From: "Nic Ferrier" <nferrier@...> ... Except that entity already has a use: to be displayed if the user hits the cancel button. An...
Seairth Jacobs
seairthjacobs
Offline Send Email
Apr 13, 2003
12:55 am

... You misunderstand me. When a user requests a protected resource the server can send back an entity body with the initial 401. The rfc says that the entity...
Nic Ferrier
nferrier_tap...
Offline Send Email
Apr 13, 2003
1:11 am

I have just given a talk about REST to the other techies at my current client (including the man in charge of development). The audience was of mixed ability,...
Nic Ferrier
nferrier_tap...
Offline Send Email
Apr 23, 2003
9:46 pm

... From: "Nic Ferrier" <nferrier@...> ... This is truly an understatement. Even when explained, it takes some implementation practice for...
Mike Dierken
mdierken
Offline Send Email
Apr 24, 2003
4:30 am

The sessions issue seems like a Red Herring. You make UI web servers that interact with the web service. They can be as stateful as you want them to be...
S. Alexander Jacobson
shop2it
Offline Send Email
May 1, 2003
12:07 am

... Well, somewhere in the message anyhow. ... I'd say so. ... Yep. Any application of cookies breaks REST, because they are by definition stateful, and all...
Mark Baker
gonga_thrash
Offline Send Email
Apr 13, 2003
3:37 am

... definition ... mean ... doing ... At least three frequently asked questions are contained in that paragraph: 1. Cookies vs REST? 2. Sessions vs REST? 3....
bhaugen32
Offline Send Email
Apr 13, 2003
12:38 pm

... But on one level are cookies not pieces of state representation that get transferred between client and server? Isn't it just the fact that they 'stick'...
sem_antico
Offline Send Email
Apr 13, 2003
4:43 pm

... Not really. Cookies aren't the state, they're "receipts" for the state. e.g. if you login to a web site using cookies, your browser just gets an opaque...
Mark Baker
gonga_thrash
Offline Send Email
Apr 14, 2003
10:54 am

... That concept tends to be a little confusing, partly because HTTP, like many network protocols, has a notion of stateless interactions that only refers to...
Roy T. Fielding
roy_fielding
Offline Send Email
Apr 16, 2003
3:34 am

Hi Roy, ... Right. Correct me if I'm wrong, but I've always assumed that this additional constraint is a constraint on application semantics. That is, that a...
Mark Baker
gonga_thrash
Offline Send Email
Apr 16, 2003
3:06 pm

... Well, keep in mind that the actions of PUT and POST also defer the maintenance of state to the server. Since we could construct a login semantic via the...
Roy T. Fielding
roy_fielding
Offline Send Email
Apr 16, 2003
6:48 pm

Oi, LOGIN was a terrible example. I didn't think it through. What I was trying to learn by asking was this; what am I constrained from doing with the...
Mark Baker
gonga_thrash
Offline Send Email
Apr 17, 2003
3:40 am

... Oh, I see what you mean. If you look back in my dissertation, http://www.ics.uci.edu/~fielding/pubs/dissertation/ net_arch_styles.htm#sec_3_4_3 ...
Roy T. Fielding
roy_fielding
Offline Send Email
Apr 18, 2003
12:28 am

... Roy> you will notice that there is only one constraint: Roy> communication must be stateless in nature. It is too bad that the theoretic ideals don't map...
Berend de Boer
berenddeboer
Online Now Send Email
Apr 21, 2003
7:30 pm

... That's the point, really. Where the mapping is problematic, it's not a failing of REST, it's it working as planned; it tells you that your app probably...
Mark Baker
gonga_thrash
Offline Send Email
Apr 22, 2003
3:05 am

... that ... What do you think of the attempts of Paul Prescod and others to cast state-transition models into RESTful hyperlinked resources? For example, ...
bhaugen32
Offline Send Email
Apr 19, 2003
3:11 pm

... i don't think so. however the reality of contemporary user agents dictates a more pragmatic approach. (IMHO of course). i will take two examples where i...
Vincent D Murphy
johnfoobar1
Offline Send Email
Apr 13, 2003
1:05 pm

... But having state on the server is surely fine with REST? ... If you create a 'basket' resource for my shopping on the server, the I'd imagine POST-ing new...
sem_antico
Offline Send Email
Apr 13, 2003
4:37 pm

... of course. i'm not sure how that contradicts what i said though. i'm referring to the fact that you have to 'build up' the shopping basket ...
Vincent D Murphy
johnfoobar1
Offline Send Email
Apr 14, 2003
7:09 am

... Yes, for current implementations. Eventually, someone points out the security hole and some poor sap is assigned to make the browser compliant with one or...
Roy T. Fielding
roy_fielding
Offline Send Email
Apr 16, 2003
2:40 am

... I think that is the answer - the representation of the items that I can buy will contain a pointer to _my_ basket. Thats what I meant when I said I have to...
Richard Padley
sem_antico
Offline Send Email
Apr 14, 2003
8:42 am

... yes. the representations generated can differ depending on whether there is a logged in session; e.g. include some HTML form UI which does a POST to the...
Vincent D Murphy
johnfoobar1
Offline Send Email
Apr 14, 2003
1:46 pm

... After reading carefully, I'm not sure I can discern any additional constraint in the above. I'm starting with the assumption that without "application...
Walden Mathews
waldenmathews
Offline Send Email
Apr 16, 2003
3:26 pm

... Consider that a single LOGIN message may be stateless (semantically self-contained), yet have consequences for the interpretation of the semantics of...
Mark Baker
gonga_thrash
Offline Send Email
Apr 16, 2003
4:57 pm

Oh, then we have the same question afterall. WM ... From: "Mark Baker" <distobj@...> To: "Roy T. Fielding" <fielding@...> Cc:...
Walden Mathews
waldenmathews
Offline Send Email
Apr 17, 2003
11:31 am

It's the Principle of Beneficint Difficulty at work, as Michael Jackson would say. WM ... From: "Mark Baker" <distobj@...> To:...
Walden Mathews
waldenmathews
Offline Send Email
Apr 22, 2003
11:26 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help