how to add extension header to websocket to make it support compressing
Just 开发者_开发知识库as mention in the draft, websocket protocol is designed to be extended and we can use extensions that had registered. For example extension deflate-application-data that can do some compressing jobs during data transmitting, detail is here. Well, it maybe has a bit troubles in design but it's not the point.
My question is that how can we use these extensions? We create a websocket like this:
var socket = new WebSocket('ws://game.example.com:12010/updates');
Websocket api seems not provide such chance to add or modify websocket protocol header. Dose the websocket api not support extensions currently?
This isn't an extension that you specify explicitly in your JavaScript code. If the browser supports this extension it will automatically add the deflate-frame
token to the Sec-WebSocket-Extensions
header. If the server supports it as well then it will specify the same token in its response. However, I'm not sure whether any browsers support this extension already, most likely not. At least Firefox definitely doesn't even though it supports deflate-stream
starting with Firefox 6.
精彩评论