Skip to content

Commit

Permalink
ending a response when the last write was not flushed
Browse files Browse the repository at this point in the history
might result in incomplete sends -> wait for the
drain event before ending the request.
  • Loading branch information
fjakobs committed Jan 5, 2011
1 parent 66c4e10 commit cf965a1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/socket.io/transports/xhr-polling.js
Expand Up @@ -72,8 +72,16 @@ Polling.prototype._write = function(message){
if (this.request.headers.cookie) headers['Access-Control-Allow-Credentials'] = 'true';
}
this.response.writeHead(200, headers);
this.response.write(message);
this.response.end();
this._onClose();
var flushed = this.response.write(message);
if (flushed) {
this.response.end();
this._onClose();
} else {
var self = this;
this.response.connection.on("drain", function() {
self.response.end();
self._onClose();
});
}
}
};

0 comments on commit cf965a1

Please sign in to comment.