Meta question; what's the best way to format a FAQ in PurpleWiki?? (4ZO)
Introduction (4ZP)
This is a list of frequently asked/answered questions about "state" in the context of network based and distributed software systems. It was created because the author has observed frequent misunderstandings of this subject. What better way than a FAQ to address such a situation? (4ZQ)
It is not specific to REST, but much of the confusion about state comes up in REST contexts because REST places tight constraints on it. (50H)
It's on a Wiki rather than elsewhere, because a non-Wiki FAQ just seems so ... 1989. (4ZR)
Part 1; Basics/Terminology? (4ZS)
1.1 What does it mean for something to be stateful or stateless? (4ZT)
In general it just means that the entity encapsulates state (or not, for stateless), where state can be thought of as a set of data or attributes or properties belonging to the entity. (4ZU)
1.2 What does it mean for a server or client to be stateful or stateless? (4ZV)
In common use, it normally means, as in 1.1, that the component - the server or client - encapsulates state. Unfortunately, "stateless server" is also sometimes used to refer to stateless protocols. (4ZW)
1.3 What does it mean for a protocol to be stateful or stateless? (4ZX)
If a protocol is stateless, it means that it doesn't require that the server maintain any session state between messages; instead, all session state is maintained by the client. (4ZY)
Roy Fielding, in his dissertation defined statelessness as; (503)
[...]each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. (504)
1.4 What is a session? What is session state? (4ZZ)
A session, in the common use of the term, refers to a series of related messages. "Session state" refers to the state which identifies where in the series of messages a client currently is. An example of a session would be the messages sent between an FTP login and logout in order to download a file, while an example of "session state" would be the state associated with the FTP connection, including the current directory, the user name and password, and the transfer mode (binary vs. ascii). Note that FTP is stateful because session state is maintained on the server, while HTTP is stateless because it's maintained on the client. (500)
In web applications (HTTP/HTML), sessions are often implemented in server side languages such as PHP. This is done by sending an identifier (SessionId?) with each request (often stored as a Cookie). (689)
1.5 What is application state? (505)
Application state normally used as a synonym for session state. However sometimes it's used to refer to resource state. (506)
1.6 What is resource state? (507)
Resource state is your application data, for example the invoice and billing data in an accounting system, or the vehicle information in a fleet management system. (508)
1.7 Doesn't the use of persistent connections in HTTP imply state? (509)
No. Connections are stateful only when state is associated with them, as with the FTP example above. See 2.1 for more detail. (50A)
Part 2; Advanced topics (50B)
2.1 Can a message which references resource state still be stateless? (50C)
Yes, unless by "reference" it is meant that the semantics of the message are a function of that state; if that's the case, then it is in fact a stateful interaction. An HTTP message which happens to include a URI is referencing state, but as long as the meaning of the message is dependent only on the URI and not the state it references, it's still stateless. (50D)
This highlights a short-coming with the answers in Part 1, since it isn't made clear that a particular datum can be, simultaneously, both resource and session state. If somebody has any desire to rewrite part 1 to explain things solely in terms of the location of state, rather than "type" of state, please feel free. (50E)
How about viewstate in ASP. This is stored at the client, but is completely meaningless in itself. (68A)
Part 3; Examples (50F)
TBD (50G)