Is it possible to receive out-of-order responses with HTTP?

前端 未结 3 1082
别那么骄傲
别那么骄傲 2020-12-09 12:39

Sec 8.1.2.2 Pipelining says:

\"A server MUST send its responses to requests in the same order that the requests were received\".

3条回答
  •  囚心锁ツ
    2020-12-09 13:27

    RFC 2616 uses the term "pipelining" to refer to this:

    • HTTP requests and responses can be pipelined on a connection. Pipelining allows a client to make multiple requests without waiting for each response, allowing a single TCP connection to be used much more efficiently, with much lower elapsed time.

    So pipelining here means using a persistent HTTP connection to make multiple requests. This is functionality that has to be supported by the browser, and currently it is either unsupported or off by default for pretty much every browser. So right now, when you make a number of plain AJAX requests there is always the possibility that responses will return out of order.

    Most of the time this is not a problem. When it is, you can take appropriate measures to "pipeline" the requests manually; they still go out on separate connections, but your code is engineered to wait until a pending request has completed before issuing the next one. In the article you link to, this functionality is built into Spine.

提交回复
热议问题