Permalink
Browse files

ensure backwards compatibility

  • Loading branch information...
1 parent 8a90bf5 commit a9f81a59c285d2f2e0392e9b5059e7fb03212d61 @einaros einaros committed Oct 25, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 support/node-websocket-client/lib/websocket.js
@@ -502,7 +502,7 @@ var WebSocket = function(url, proto, opts) {
}
var httpReq = http.request(opt, function() { });
- httpReq.on('upgrade', (function() {
+ var upgradeHandler = (function() {
var data = undefined;
return function(req, s, head) {
@@ -597,7 +597,9 @@ var WebSocket = function(url, proto, opts) {
stream.emit('data', head);
};
- })());
+ })();
+ agent.on('upgrade', upgradeHandler); // node v0.4
+ httpReq.on('upgrade', upgradeHandler); // node v0.5+
httpReq.write(challenge, 'binary');
httpReq.end();

0 comments on commit a9f81a5

Please sign in to comment.