Skip to content

Commit

Permalink
Using url parameter for communicating the need for base64 instead of …
Browse files Browse the repository at this point in the history
…upgrade packet for WebSockets
  • Loading branch information
Tony Kovanen committed Feb 3, 2014
1 parent 7723e8a commit 4415959
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Server.prototype.handshake = function(transport, req){

try {
var transport = new transports[transport](req);
if (req.query && req.query.b64) transport.supportsBinary = false;
if (req.query && req.query.b64) { transport.supportsBinary = false; }
}
catch (e) {
sendErrorMessage(req.res, Server.errors.BAD_REQUEST);
Expand Down Expand Up @@ -283,6 +283,7 @@ Server.prototype.onWebSocket = function(req, socket){
} else {
debug('upgrading existing transport');
var transport = new transports[req.query.transport](req);
if (req.query && req.query.b64) { transport.supportsBinary = false; }
this.clients[id].maybeUpgrade(transport);
}
} else {
Expand Down
1 change: 0 additions & 1 deletion lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ Socket.prototype.maybeUpgrade = function (transport) {
transport.send([{ type: 'pong', data: 'probe' }]);
self.checkIntervalTimer = setInterval(check, 100);
} else if ('upgrade' == packet.type && self.readyState == 'open') {
if (packet.data === 'b64') { transport.supportsBinary = false; }
debug('got upgrade packet - upgrading');
self.upgraded = true;
self.emit('upgrade', transport);
Expand Down
2 changes: 1 addition & 1 deletion lib/transports/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ WebSocket.prototype.onData = function (data) {

WebSocket.prototype.send = function (packets) {
for (var i = 0, l = packets.length; i < l; i++) {
var data = parser.encodePacket(packets[i]);
var data = parser.encodePacket(packets[i], this.supportsBinary);
debug('writing "%s"', data);
this.writable = false;
var self = this;
Expand Down

0 comments on commit 4415959

Please sign in to comment.