如果HTTP/1.1客户端与仅HTTP/2的服务器通信,该怎么办?如果HTTP/2客户端与仅HTTP/1.1的服务器通信,该怎么办? [英] What if an HTTP/1.1 client talk to an HTTP/2 only server and what if an HTTP/2 client talk to an HTTP/1.1 only server?

查看:176
本文介绍了如果HTTP/1.1客户端与仅HTTP/2的服务器通信,该怎么办?如果HTTP/2客户端与仅HTTP/1.1的服务器通信,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP/2绝对是未来的趋势,因为它已成为HTTP协议的标准.正如我们在我可以使用中看到的那样,有70.15%的浏览器支持HTTP/2.但是HTTP/2太新了,以至于有些浏览器仅支持HTTP/1.x,许多服务器仅支持HTTP/1.x.我知道客户端可以使用HTTP升级机制来协商适当的协议以与服务器进行通信.例如,如果服务器支持HTTP/2,则它们的通信协议将切换为HTTP/2,否则,将使用HTTP/1.x.但这仅适用于以下情形:客户端使用的浏览器同时支持HTTP/2和HTTP/1.x,对吗?

HTTP/2 is definitely the future trend because it is now the standard of HTTP protocol. As we can see in Can I use, 70.15 percent of browsers support the HTTP/2. But HTTP/2 is so new that there are browsers that only support HTTP/1.x and there are many servers that only support HTTP/1.x. I knew that a client can use HTTP upgrade mechanism to negotiate a proper protocol to communicate with the server. For example, if the server supports HTTP/2, their communicating protocol will switch to HTTP/2, otherwise, HTTP/1.x is used. But this only applies to the situdation where the browser the clients used supports both HTTP/2 and HTTP/1.x, right?

但是,如果仅支持HTTP/1.x的浏览器上的用户想要与仅HTTP/2的服务器通信,该怎么办?服务器会忽略请求还是将错误发送回用户?

But what if a user on a browser that only supports HTTP/1.x wants to communicate with HTTP/2 only server? Will the server ignore the request or send an error back to the user?

如果仅支持HTTP/2的浏览器上的用户想要与仅HTTP/1.1的服务器通信,该怎么办?我认为该过程可能是这样的:用户向服务器发送连接序,服务器无法识别该请求,因此用户可能会收到连接错误消息.是这样吗?

And what if a user on a brower that only supports HTTP/2 wants to communicate with HTTP/1.1 only server? I am thinking the process might go like this: The user sends a connecion preface to the server, the server cannot recognize the request, so the user might receive a connection error message. Is this right?

或者是否有仅支持HTTP/2的浏览器?

Or is there any browser that supports only HTTP/2?

推荐答案

如果浏览器仅支持HTTP/1.1,而服务器仅支持HTTP/2,则它们将无法通信.服务器将无法识别客户端发送的内容(特别是将没有连接前言,服务器会按照规范将其视为连接错误),并将关闭连接.

If a browser only supports HTTP/1.1 and the server only supports HTTP/2, they cannot communicate. The server will not recognize what the client sends (in particular there will be no connection preface, which the server treats - following the specification - as a connection error), and will close the connection.

仅支持HTTP/2的浏览器"不存在;如果它们支持HTTP/2,则它们也支持HTTP/1.1.但是,假设存在这样的浏览器.

"A browser that only supports HTTP/2" does not exist; if they support HTTP/2, they also support HTTP/1.1. But let's assume that such browser exist.

在后一种情况下,服务器将看到连接前言,并且将无法识别PRI方法.在这种情况下,服务器的确切功能取决于服务器.它可能返回400 Bad Request,或者可能只是关闭连接,或者可能触发内部服务器错误.

In this latter case, the server will see the connection preface and will not recognize the PRI method. What exactly the server does in this case depends on the server. It may return a 400 Bad Request, or perhaps just close the connection, or it may trigger an internal server error.

这篇关于如果HTTP/1.1客户端与仅HTTP/2的服务器通信,该怎么办?如果HTTP/2客户端与仅HTTP/1.1的服务器通信,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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