概念幂等和安全方法有何不同?
How does concepts idempotent and safe methods differ?
试图理解幂等和安全方法的核心概念,但我没有弄清楚。根据我的分析
- 幂等方法 - 可以使用相同的输入多次调用并产生相同的结果。
- 安全方法 - 不修改服务器端的资源。
Http 方法分类如下。
- GET、HEAD、OPTIONS 是安全且幂等的
- PUT、DELETE 不安全但幂等
- POST,PATCH 既不安全也不幂等
帮助我了解更多细节w.r.t服务器端HTTP方法的内部机制以及与幂等的安全性差异
除资源修改和产品相同结果外,是否还有任何其他特征可用于描述幂等和安全方法。
Help me understand with more details w.r.t internal mechanism of HTTP methods on server side and how safe differ from idempotent
两者safe and idempotent都描述了处理请求的语义。
Request methods are considered "safe" if their defined semantics are essentially read-only; i.e., the client does not request, and does not expect, any state change on the origin server as a result of applying a safe method to a target resource.
安全方法是 cqrs 意义上的查询 - 它们不会更改任何内容,它们通常包括对资源状态的读取,但不包括对资源状态的修改。
安全请求处理使资源处于相同状态,因此安全方法也必然是幂等的。
A request method is considered "idempotent" if the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request.
幂等请求处理的意思是,如果客户端发送请求,但没有得到答复,客户端可以重复请求。
幂等请求处理基本上意味着服务器仅根据请求计算资源的最终状态(不考虑资源的当前状态)。第二次处理消息时,将计算并应用相同的新状态。
这大致类似于赋值。
// the previous value of x was 10, say
set(x, 7) // and now the value of x is 7
set(x, 7) // and now the value of x is still 7
在 HTTP 中,方法 PUT and DELETE 被定义为具有幂等语义。请注意这些方法的共同点:客户端知道资源的最终状态应该是什么,并要求服务器实现它。
如果您对请求的处理类似于
// the previous value of x was 10, say
increment(x, 7) // and now the value of x is 17
increment(x, 7) // and now the value of x is 24
那么你对请求的处理不是幂等的。
注意这里重要的是语义。这是 Fielding had to say in 2002
HTTP does not attempt to require the results of a GET to be safe. What it does is require that the semantics of the operation be safe, and therefore it is a fault of the implementation, not the interface or the user of that interface, if anything happens as a result that causes loss of property (money, BTW, is considered property for the sake of this definition).
安全方法 - 不会更改服务器中的任何资源。
示例:获取、选项。
IDEMPOTENCY 方法 - 即使多次请求相同,也不会更改服务器的状态。
示例:获取、选项、放置、删除
所有安全方法都是幂等的,反之亦然
试图理解幂等和安全方法的核心概念,但我没有弄清楚。根据我的分析
- 幂等方法 - 可以使用相同的输入多次调用并产生相同的结果。
- 安全方法 - 不修改服务器端的资源。
Http 方法分类如下。
- GET、HEAD、OPTIONS 是安全且幂等的
- PUT、DELETE 不安全但幂等
- POST,PATCH 既不安全也不幂等
帮助我了解更多细节w.r.t服务器端HTTP方法的内部机制以及与幂等的安全性差异
除资源修改和产品相同结果外,是否还有任何其他特征可用于描述幂等和安全方法。
Help me understand with more details w.r.t internal mechanism of HTTP methods on server side and how safe differ from idempotent
两者safe and idempotent都描述了处理请求的语义。
Request methods are considered "safe" if their defined semantics are essentially read-only; i.e., the client does not request, and does not expect, any state change on the origin server as a result of applying a safe method to a target resource.
安全方法是 cqrs 意义上的查询 - 它们不会更改任何内容,它们通常包括对资源状态的读取,但不包括对资源状态的修改。
安全请求处理使资源处于相同状态,因此安全方法也必然是幂等的。
A request method is considered "idempotent" if the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request.
幂等请求处理的意思是,如果客户端发送请求,但没有得到答复,客户端可以重复请求。
幂等请求处理基本上意味着服务器仅根据请求计算资源的最终状态(不考虑资源的当前状态)。第二次处理消息时,将计算并应用相同的新状态。
这大致类似于赋值。
// the previous value of x was 10, say
set(x, 7) // and now the value of x is 7
set(x, 7) // and now the value of x is still 7
在 HTTP 中,方法 PUT and DELETE 被定义为具有幂等语义。请注意这些方法的共同点:客户端知道资源的最终状态应该是什么,并要求服务器实现它。
如果您对请求的处理类似于
// the previous value of x was 10, say
increment(x, 7) // and now the value of x is 17
increment(x, 7) // and now the value of x is 24
那么你对请求的处理不是幂等的。
注意这里重要的是语义。这是 Fielding had to say in 2002
HTTP does not attempt to require the results of a GET to be safe. What it does is require that the semantics of the operation be safe, and therefore it is a fault of the implementation, not the interface or the user of that interface, if anything happens as a result that causes loss of property (money, BTW, is considered property for the sake of this definition).
安全方法 - 不会更改服务器中的任何资源。 示例:获取、选项。
IDEMPOTENCY 方法 - 即使多次请求相同,也不会更改服务器的状态。 示例:获取、选项、放置、删除 所有安全方法都是幂等的,反之亦然