diff --git a/lib/socket.io/client.js b/lib/socket.io/client.js index 4c2c92fc54..a96af3e2d6 100644 --- a/lib/socket.io/client.js +++ b/lib/socket.io/client.js @@ -129,8 +129,11 @@ Client.prototype._onClose = function(skipDisconnect){ this.connection.destroy(); this.connection = null; } - this.request = null; - this.response = null; + if(!this.dont_clear_request){ + this.request = null; + this.response = null; + this.dont_clear_request = false; + } if (skipDisconnect !== false){ if (this.handshaked){ this._disconnectTimeout = setTimeout(function(){ diff --git a/lib/socket.io/transports/jsonp-polling.js b/lib/socket.io/transports/jsonp-polling.js index 502a9613a0..9dfb4dd5e5 100644 --- a/lib/socket.io/transports/jsonp-polling.js +++ b/lib/socket.io/transports/jsonp-polling.js @@ -29,6 +29,7 @@ JSONPPolling.prototype._write = function(message){ this.response.writeHead(200, {'Content-Type': 'text/javascript; charset=UTF-8', 'Content-Length': Buffer.byteLength(message)}); this.response.write(message); this.response.end(); + this.dont_clear_request = true; this._onClose(); } }; \ No newline at end of file diff --git a/lib/socket.io/transports/xhr-polling.js b/lib/socket.io/transports/xhr-polling.js index 13433b6945..4f3da76689 100644 --- a/lib/socket.io/transports/xhr-polling.js +++ b/lib/socket.io/transports/xhr-polling.js @@ -2,6 +2,7 @@ var Client = require('../client') , qs = require('querystring'); var Polling = module.exports = function(){ + this._keep_last_request = true; Client.apply(this, arguments); }; @@ -72,6 +73,7 @@ Polling.prototype._write = function(message){ this.response.writeHead(200, headers); this.response.write(message); this.response.end(); + this.dont_clear_request = true; this._onClose(); } }; \ No newline at end of file