如何让 Chromium 发送新的 WebSocket 握手?
我遇到了Chromium 中的此代码更改。它说 Chromium 现在支持两种握手版本,代码似乎证实了这一点。我的意思是 Wikipedia 的第二个版本(draft-ietf -hybi-thewebsocketprotocol-06)。
但是,当我连接到服务器时,我获得的唯一内容是旧版本,即包括这些标头:
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
但不是新版本,新版本将是包含以下内容的请求:
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
我在这里缺少什么?我下载了最新的夜间版本,并且它已经在两周前包含在内,所以我猜这不是原因。
如何让 WebSocket 发送新的握手版本?
I came across this code change in Chromium. It says Chromium now supports both handshake versions, which the code seems to confirm. I mean the second version at Wikipedia (draft-ietf-hybi-thewebsocketprotocol-06).
However, when I connect to my server, the only thing I obtain is the old version, i.e. including these headers:
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
but not the new version which would be a request containing:
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
What am I missing here? I downloaded the latest nightly build and it has been included more than two weeks ago, so that cannot be the cause I guess.
How can I make a WebSocket send the new handshake version?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您发布的代码链接用于握手的服务器端(这可能会在 Chrome 中的一些地方使用,例如远程调试和作为扩展的代理)。
如果您确实想使用新的 HyBi-07 协议版本,您可以尝试使用 这个我制作的 web-socket-js 的分支。一旦 Chrome 切换到新协议,web-socket-js 也会默认切换。为了使 web-socket-js 在已经支持 WebSockets 的浏览器中工作,您需要对其进行一些细微的调整以使用不同的对象名称而不是 WebSocket。
我预计 Chrome/WebKit 很快就会添加新协议。请注意,API 更改 添加二进制支持最近才决定,因此 Chrome 可能会采用新协议之前添加API 完全支持协议启用的新功能。
The code link you posted is for the server-side of the handshake (there is a few places this will likely be used in Chrome such as remote debugging and as a proxy for extensions).
If you really want use the new HyBi-07 protocol version you can try using this branch of web-socket-js that I made. Once Chrome switch to the new protocol, web-socket-js will switch by default also. In order to make web-socket-js work in a browser that already has WebSockets support you will need make some minor tweaks to it to use a different object name instead of WebSocket.
I expect Chrome/WebKit will add the new protocol before long. Note that the API changes to add binary support have only recent been decided so Chrome the new protocol may be added before the API fully supports the new functionality enabled by the protocol.
我所知道的唯一实现 07 协议的浏览器是 FF4 的此版本:
http ://www.ducksong.com/misc/websockets-builds/ws-07/
The only browser I know of that implements the 07 protocol is this build of FF4:
http://www.ducksong.com/misc/websockets-builds/ws-07/