From ffa8994a23f826f71d6c23dd6161dee562fda136 Mon Sep 17 00:00:00 2001 From: bodash Date: Wed, 2 May 2012 13:18:46 -0600 Subject: [PATCH] I continued to have websocket connection issues in Safari when using SSL that terminated at a load balancer. The shorthand logic that was here was nice and compact but didn't seem to work. Took the "intent" of the short hand and made it a bit more verbose and now it works. --- lib/transports/websocket/default.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/transports/websocket/default.js b/lib/transports/websocket/default.js index 2e861a7470..091fdd44fd 100644 --- a/lib/transports/websocket/default.js +++ b/lib/transports/websocket/default.js @@ -1,4 +1,3 @@ - /*! * socket.io-node * Copyright(c) 2011 LearnBoost @@ -89,11 +88,14 @@ WebSocket.prototype.onSocketConnect = function () { } var origin = this.req.headers['origin'] - , location = ((this.manager.settings['match origin protocol'] ? - origin.match(/^https/) : this.socket.encrypted) ? - 'wss' : 'ws') - + '://' + this.req.headers.host + this.req.url - , waitingForNonce = false; + , waitingForNonce = false; + if(this.manager.settings['match origin protocol']){ + location = (origin.indexOf('https')>-1 ? 'wss' : 'ws') + '://' + this.req.headers.host + this.req.url; + }else if(this.socket.encrypted){ + location = 'wss://' + this.req.headers.host + this.req.url; + }else{ + location = 'ws://' + this.req.headers.host + this.req.url; + } if (this.req.headers['sec-websocket-key1']) { // If we don't have the nonce yet, wait for it (HAProxy compatibility).