diff --git a/example/client b/example/client index 4697574a..41ad4057 160000 --- a/example/client +++ b/example/client @@ -1 +1 @@ -Subproject commit 4697574a68e5e24ab3cb368cb7ffbf0c2fb57d58 +Subproject commit 41ad4057f5a14fd8d86add6ad7d946ef6714ca6b diff --git a/lib/socket.io/transports/websocket.js b/lib/socket.io/transports/websocket.js index fde680d7..06d08e0c 100644 --- a/lib/socket.io/transports/websocket.js +++ b/lib/socket.io/transports/websocket.js @@ -29,29 +29,28 @@ WebSocket.prototype._onConnect = function(req, socket){ if ('sec-websocket-key1' in this.request.headers){ this.draft = 76; } - - if (this.draft == 76){ - var origin = this.request.headers.origin; + + var origin = this.request.headers.origin; + if (this.draft == 76){ headers = [ 'HTTP/1.1 101 WebSocket Protocol Handshake', 'Upgrade: WebSocket', 'Connection: Upgrade', 'Sec-WebSocket-Origin: ' + (origin || 'null'), - 'Sec-WebSocket-Location: ws://' + this.request.headers.host + this.request.url + 'Sec-WebSocket-Location: ' + origin.replace(/^http/, 'ws') + this.request.url ]; if ('sec-websocket-protocol' in this.request.headers){ headers.push('Sec-WebSocket-Protocol: ' + this.request.headers['sec-websocket-protocol']); } } else { - headers = [ 'HTTP/1.1 101 Web Socket Protocol Handshake', 'Upgrade: WebSocket', 'Connection: Upgrade', - 'WebSocket-Origin: ' + this.request.headers.origin, - 'WebSocket-Location: ws://' + this.request.headers.host + this.request.url + 'WebSocket-Origin: ' + origin, + 'WebSocket-Location: ' + origin.replace(/^http/, 'ws') + this.request.url ]; try {