想知道是否有人可以提供一个令人信服的解释,在流水线环境下,http 1.1是半双工还是全双工?据我所知,在客户端得到响应之前,可以通过同一个持久连接发送多个请求。那么,这是否意味着服务器可以在客户端发送新请求时响应上一个请求?
最佳答案
让我们看看标准,在这种情况下RFC-2616。我们在第8.1.1段中发现,持续连接:
- 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.
稍后在文档中:
8.1.2.2 Pipelining
A client that supports persistent connections MAY "pipeline" its
requests (i.e., send multiple requests without waiting for each
response). A server MUST send its responses to those requests in the
same order that the requests were received.
在这两种情况下,都清楚地说明了客户端可以发送请求而无需等待响应,我认为可以安全地声明http 1.1支持全双工。
编辑:在取代RFC-2616的RFC集合的RFC-7230中,此语句变为:
A client that supports persistent connections MAY "pipeline" its
requests (i.e., send multiple requests without waiting for each
response). A server MAY process a sequence of pipelined requests in
parallel if they all have safe methods (Section 4.2.1 of [RFC7231]),
but it MUST send the corresponding responses in the same order that
the requests were received.