Commit 7feee194 authored by bradleymeck's avatar bradleymeck

[fix] only set one drain listener while paused

parent a7269653
......@@ -224,6 +224,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
// If the res socket has been killed already, then write()
// will throw. Nevertheless, try our best to end it nicely.
//
var paused = false;
response.on('data', function (chunk) {
if (req.method !== 'HEAD' && res.writable) {
try {
......@@ -238,9 +239,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
return;
}
if (!flushed) {
if (!flushed && !paused) {
paused = true;
response.pause();
res.once('drain', function () {
paused = false;
try { response.resume() }
catch (er) { console.error("response.resume error: %s", er.message) }
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment