diff --git a/lib/http.js b/lib/http.js index ef2f10255f..6904fab22f 100644 --- a/lib/http.js +++ b/lib/http.js @@ -411,7 +411,7 @@ OutgoingMessage.prototype.write = function (chunk, encoding) { }; OutgoingMessage.prototype.flush = function () { - this.emit("flush"); + this._onFlush(); }; OutgoingMessage.prototype.finish = function () { @@ -566,7 +566,6 @@ function flushMessageQueue (socket, queue) { if (!message.finished) break; - message.emit("sent"); queue.shift(); if (message.closeOnFinish) return true; @@ -664,11 +663,11 @@ function connectionListener (socket) { var res = new ServerResponse(req); res.shouldKeepAlive = shouldKeepAlive; - res.addListener('flush', function () { + res._onFlush = function () { if (flushMessageQueue(socket, responses)) { socket.end(); } - }); + }; responses.push(res); self.emit('request', req, res); @@ -716,7 +715,7 @@ function Client ( ) { }; self._pushRequest = function (req) { - req.addListener("flush", function () { + req._onFlush = function () { if (self.readyState == "closed") { debug("HTTP CLIENT request flush. reconnect. readyState = " + self.readyState); self._reconnect(); @@ -725,7 +724,7 @@ function Client ( ) { debug("self flush readyState = " + self.readyState); if (req == currentRequest) flushMessageQueue(self, [req]); - }); + }; requests.push(req); };