REST six constraints: 2. stateless

2. stateless: 无状态

处理请求的必要状态包含在请求本身中,
请求的必要状态: URI, query-string parameters, body, or headers

服务器处理请求后回传给客户端的状态都包含在响应中:
headers, status and response body.

也就是说客户端和服务器之间通过 请求本身 和 响应本身 交换状态。

So what's the difference between state and a resource?

State, or application state, is that which the server cares about to fulfill a request—data necessary for the current session or request. A resource, or resource state, is the data that defines the resource representation—the data stored in the database, for instance. Consider application state to be data that could vary by client, and per request. Resource state, on the other hand, is constant across every client who requests it.

那么state和resoure之间的区别是什么? 状态或应用程序状态是服务器关心的,以满足当前会话或请求所需的请求数据。 资源或资源状态是定义资源表示的数据 - 例如,存储在数据库中的数据。 将应用程序状态视为可能因客户端和每个请求而异的数据。 另一方面,资源状态在请求它的每个客户端都是不变的。

state: 是服务器关心的, 以满足当前请求所需的请求数据;

resource: 定义资源表示的数据,例如存在数据库中的数据。

总结起来就是:

通过请求信息和响应信息交换状态, 状态: 是指数据的变更。

你可能感兴趣的:(REST six constraints: 2. stateless)