Skip to content

Commit

Permalink
Updated client
Browse files Browse the repository at this point in the history
Fixed WebSocket location header for ws/wss (Thanks @jdub, Fixes #40)
  • Loading branch information
rauchg committed Aug 31, 2010
1 parent 39bc175 commit c023fae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/client
Submodule client updated from 469757 to 41ad40
13 changes: 6 additions & 7 deletions lib/socket.io/transports/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c023fae

Please sign in to comment.