1

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?

1
  • Websockets' packets are small, compressing it will produce longer data length than uncompressed, unless you send and receive larger chunks of data ~150 bytes. Commented Mar 30, 2012 at 22:15

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I got how the extensions work now. And I test firefox 6 and found it do send deflate-stream header to server. But why you said "it definitely doesn't"? Is that means firefox just send a deflate-stream header but its payload isn't compressed at all? I can't find any websocekt server that supports deflate to check out the result currently. Can you provide any advanced info links? Thanks again~ :)
@changchang: deflate-stream and deflate-frame are two different things. Firefox supports the former but not the latter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.