gpt4 book ai didi

http - 为什么 websocket 协议(protocol)的设计者不使用 WS 而不是 GET 作为方法?

转载 作者:可可西里 更新时间:2023-11-01 15:27:45 25 4
gpt4 key购买 nike

我想知道为什么 websocket 协议(protocol)的设计者决定使用 GET 方法而不是创建一个名为“WS”的新方法?

因为很多框架都可以通过方法和 url 进行路由,所以这会很酷。是否有理由反对新方法?

最佳答案

来自 RFC 6455 , 第 1.3 节:

The opening handshake is intended to be compatible with HTTP-basedserver-side software and intermediaries, so that a single port can beused by both HTTP clients talking to that server and WebSocketclients talking to that server.

和 1.8:

When a connection is to be made to a port that is shared by an HTTPserver (a situation that is quite likely to occur with traffic toports 80 and 443), the connection will appear to the HTTP server tobe a regular GET request with an Upgrade offer. In relatively simplesetups with just one IP address and a single server for all trafficto a single hostname, this might allow a practical way for systemsbased on the WebSocket Protocol to be deployed.

这需要对 Web 服务器本身进行很少或不需要配置,因为支持它的编程语言可以轻松扩展以理解和执行到 WebSockets 的 channel 升级。引入新的请求方法需要 HTTP 服务器理解此方法。

如果您真的对原因感兴趣,请随时搜索/阅读 http://www.ietf.org/mail-archive/web/hybi/邮件列表。我认为处理此问题的讨论标题为 “关于 WEBSOCKET 与现有方法(是关于 GET 与 OPTIONS 与新方法的投票)”


这是一个巨大的阅读,从 here 开始.在草案 05 中,GET was chosen之后从未改变:

Joe and I, as chairs, haven't seen emerging any significant consensus from this straw-poll; so we suggest to move forward with no change of method for the upcoming 05 version,keeping GET as method for the handshake,as its behavior in the WebSocket handshake has been largely tested in the fieldand it is now well know for better and worse.

关于http - 为什么 websocket 协议(protocol)的设计者不使用 WS 而不是 GET 作为方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18079999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com