Mikulas Dite
Mikulas Dite

Reputation: 7941

WebSockets server: reading data after handshake

I've managed to get the socket opened, hands shaken, and even though that's all fun and so, I would like to handle the data itself now. The small thingy is that unlike the HTTP headers which are pure ascii, the content seems to be encoded:

ÅÅúÅ à›ÅÅ»öë∑âÅÅ«∆{UÅÅeæƒ$ÅÅvü
‡7ÅÅŸJêÏòÅÅ~}Z¥?ÅÅ9TÉHxÅÅ[ 1†ÅÅs    óE2ÅÅ9\ÅyxÅÅ#´°ºbÅÅïôx ‘ÅÅ)Ÿ1–hÅÅ⁄}

That's what server received from Google Chrome client's

socket.send("A");
socket.send("A");

Just skimming the protocol definition, I didn't find anything about encoding besides base64, which this clearly isn't.

How should I handle the content serverside?

Edit: already looked quite a few articles, but nearly all are about the client side.

Upvotes: 1

Views: 705

Answers (1)

kanaka
kanaka

Reputation: 73187

Data that is sent from the client to the server is masked (to protect misbehaving intermediaries from getting confused). It's a 4 byte running XOR with the mask sent as the first 4 bytes of the payload. It is described in the spec in section 5.3

Upvotes: 1

Related Questions