From 29e867aaa062e6d05e3469aa16a5f4089c294033 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 26 May 2010 13:37:06 -0700 Subject: [PATCH] Simplify a few internal HTTP events. --- lib/http.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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); };