0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00

Simplify a few internal HTTP events.

This commit is contained in:
Ryan Dahl 2010-05-26 13:37:06 -07:00
parent 311a62dea7
commit 29e867aaa0

View File

@ -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);
};