spine.js:它真的“管道”POST吗? [英] spine.js: Does it really 'pipeline' POSTs?

查看:120
本文介绍了spine.js:它真的“管道”POST吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Alex Maccaw的帖子,他说:

I was reading this post from Alex Maccaw, where he states :


最后一个问题是并行发送的Ajax请求。如果用户创建记录,然后立即更新同一记录,则会同时发送两个Ajax请求, POST 和PUT。但是,如果服务器在创建之前处理更新请求,它就会吓坏。它不知道哪条记录需要更新,因为还没有创建记录。

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.

这个解决方案是管道Ajax请求,以串行方式传输它们。 Spine默认执行此操作,排队 POST ,PUT和DELETE Ajax请求,以便一次发送一个。只有在前一个请求成功返回后才发送下一个请求。

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 说:


客户端不应该使用非幂等方法或非幂等方法序列来管道请求(参见第9.1.2节)。否则,提前终止传输连接可能会导致不确定的结果。

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吗?

So, does Spine really 'pipeline' POSTs ?

推荐答案

Maccaw对术语管道化的使用与HTTP规范的使用在这里并不相同。实际上,它们正好相反。

Maccaw's usage of the term "pipelineing" and that of the HTTP spec are not the same here. Actually, they're opposite.

在HTTP规范中,术语流水线意味着在不等待响应的情况下发送多个请求。 请参阅第8.1.2.2节

In the HTTP spec, the term "pipelining" means sending multiple requests without waiting for a response. 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).

根据这个定义,您可以看到为什么规范强烈反对非幂等请求的流水线操作,因为其中一个流水线请求可能会改变应用程序的状态,意想不到的结果。

Based on this definition, you can see why the spec would strongly discourage pipelining non-idempotent requests, as one of the pipelined requests might change the state of the app, with unexpected results.

当Maccaw写关于脊椎的流水线时,他实际上指的是 解决方案 根据HTTP规范,客户端将管道化请求而不等待响应。也就是说,spinejs将对请求进行排队并按顺序提交,每个连续请求仅在其前任完成后才会生成。

When Maccaw writes about spine's "pipelining", he's actually referring to the solution to the fact that the client will "pipeline" requests without waiting for a response, as per the HTTP spec. That is, spinejs will queue the requests and submit them serially, each consecutive request being made only after its predecessor completes.

这篇关于spine.js:它真的“管道”POST吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆