Emit drain if it doesn't happen on its own in 100ms

This commit is contained in:
indexzero 2011-09-08 16:36:19 -07:00
parent 6a7fd14bfa
commit 37e2541891

View File

@ -240,6 +240,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
res.once('drain', function () {
response.resume();
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout(function () {
res.emit('drain');
}, 100);
}
}
});
@ -281,6 +289,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
reverseProxy.once('drain', function () {
req.resume();
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout(function () {
reverseProxy.emit('drain');
}, 100);
}
}
});
@ -356,6 +372,14 @@ HttpProxy.prototype._forwardRequest = function (req) {
forwardProxy.once('drain', function () {
req.resume();
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout(function () {
forwardProxy.emit('drain');
}, 100);
}
});
@ -448,6 +472,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
reverseProxy.incoming.socket.once('drain', function () {
proxySocket.resume();
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout(function () {
reverseProxy.incoming.socket.emit('drain');
}, 100);
}
}
catch (ex) {
@ -471,6 +503,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
proxySocket.once('drain', function () {
reverseProxy.incoming.socket.resume();
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout(function () {
proxySocket.emit('drain');
}, 100);
}
}
catch (ex) {
@ -635,6 +675,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
socket.once('drain', function () {
reverseProxy.socket.resume();
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout(function () {
socket.emit('drain');
}, 100);
}
}
catch (ex) {