javascript - pine.js:真的是 'pipeline' POST 吗?

标签 javascript ajax http spine.js

我正在读这篇文章post来自 Alex Maccaw,他说:

The last issue is with Ajax requests that get sent out in parallel. If a user creates a record, and then immediately updates the same record, two Ajax requests will be sent out at the same time, a POST and a PUT. However, if the server processes the 'update' request before the 'create' one, it'll freak out. It has no idea what record needs updating, as the record hasn't been created yet.

The solution to this is to pipeline Ajax requests, transmitting them serially. Spine does this by default, queuing up POST, PUT and DELETE Ajax requests so they're sent one at a time. The next request sent only after the previous one has returned successfully.

但是 HTTP 规范 Sec 8.1.2.2 Pipelining 说:

Clients SHOULD NOT pipeline requests using non-idempotent methods or non-idempotent sequences of methods (see section 9.1.2). Otherwise, a premature termination of the transport connection could lead to indeterminate results.

那么,Spine 真的“管道”POST 吗?

最佳答案

Maccaw 对术语“管道”的使用和 HTTP 规范中的使用并不相同。事实上,他们是相反的。

在 HTTP 规范中,术语“管道”意味着发送多个请求而不等待响应。 See section 8.1.2.2 .

A client that supports persistent connections MAY "pipeline" its requests (i.e., send multiple requests without waiting for each response).

根据此定义,您可以明白为什么规范强烈反对管道化非幂等请求,因为管道化请求之一可能会更改应用程序的状态,从而产生意外结果。

当Maccaw写到spine的“管道化”时,他实际上指的是解决方案,即客户端将“管道化”请求而不等待响应,如下所示根据 HTTP 规范。也就是说,spinejs 会将请求排队并串行提交,每个连续的请求仅在其前一个请求完成后才会发出。

关于javascript - pine.js:真的是 'pipeline' POST 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16290134/

相关文章:

javascript - 使用 lodash 从与正则表达式匹配的数组中获取值

rest - WCF REST 服务 HTTP/HTTPS 端口共享

javascript - 访问 cookie,希望在 JavaScript 中

javascript - Node api 不向客户端 ajax 请求返回数据

javascript - 如何在 Laravel 5.2 中获取 AJAX 表记录

javascript - AJAX 请求 jQuery 中的 this 关键字

angular - http GET 工作时,angular 2 客户端中的 http POST 不工作

asp.net - 通过 HTTP header 将值从一个 ASP.NET 应用程序传递到另一个

javascript - 带字符串的 Object.prototype.toString.call 的结果

javascript - 有人可以建议我体素化 3d 模型的方法吗?