Commit 5575bcf6 authored by indexzero's avatar indexzero

[minor] Remove commented out debug statements.

parent 558a8a4f
......@@ -349,6 +349,7 @@ HttpProxy.prototype.buffer = function (obj) {
this.resume = function () {
console.error("Cannot resume buffer after destroying it.");
};
onData = onEnd = events = obj = null;
},
resume: function () {
......@@ -414,9 +415,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
try {
res.writeHead(404);
res.end();
} catch (er) {
}
catch (er) {
console.error("res.writeHead/res.end error: %s", er.message);
}
return;
}
......@@ -492,11 +495,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
}
}
try {
res.end();
} catch (er) {
console.error("res.end error: %s", er.message);
}
try { res.end() }
catch (er) { console.error("res.end error: %s", er.message) }
}
outgoing = {
......@@ -524,11 +524,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
// `response.statusCode === 304`: No 'data' event and no 'end'
if (response.statusCode === 304) {
try {
res.end();
} catch (er) {
console.error("res.end error: %s", er.message)
}
try { res.end() }
catch (er) { console.error("res.end error: %s", er.message) }
return;
}
......@@ -540,26 +537,24 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
if (req.method !== 'HEAD' && res.writable) {
try {
var flushed = res.write(chunk);
} catch (er) {
console.error("res.write error: %s", er.message);
try {
res.end();
} catch (er) {
console.error("res.end error: %s", er.message);
}
catch (er) {
console.error("res.write error: %s", er.message);
try { res.end() }
catch (er) { console.error("res.end error: %s", er.message) }
return;
}
}
if (!flushed) {
//console.error('backpressure 554');
response.pause();
res.once('drain', function () {
try {
response.resume();
} catch (er) {
console.error("response.resume error: %s", er.message);
}
try { response.resume() }
catch (er) { console.error("response.resume error: %s", er.message) }
});
setTimeout(function () {
res.emit('drain');
}, 100);
......@@ -574,11 +569,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
response.on('end', function () {
if (!errState) {
reverseProxy.removeListener('error', proxyError);
try {
res.end();
} catch (er) {
console.error("res.end error: %s", er.message);
}
try { res.end() }
catch (er) { console.error("res.end error: %s", er.message) }
// Emit the `end` event now that we have completed proxying
self.emit('end', req, res);
......@@ -595,15 +588,13 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
if (!errState) {
var flushed = reverseProxy.write(chunk);
if (!flushed) {
//console.error('backpressure 594');
req.pause();
reverseProxy.once('drain', function () {
try {
req.resume();
} catch (er) {
console.error("req.resume error: %s", er.message);
}
try { req.resume() }
catch (er) { console.error("req.resume error: %s", er.message) }
});
setTimeout(function () {
reverseProxy.emit('drain');
}, 100);
......@@ -625,7 +616,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
if (options.buffer) {
if (!errState) {
options.buffer.resume();
} else {
}
else {
options.buffer.destroy();
}
}
......@@ -677,15 +669,13 @@ HttpProxy.prototype._forwardRequest = function (req) {
req.on('data', function (chunk) {
var flushed = forwardProxy.write(chunk);
if (!flushed) {
//console.error('backpressure 672');
req.pause();
forwardProxy.once('drain', function () {
try {
req.resume();
} catch (er) {
console.error("req.resume error: %s", er.message);
}
try { req.resume() }
catch (er) { console.error("req.resume error: %s", er.message) }
});
setTimeout(function () {
forwardProxy.emit('drain');
}, 100);
......@@ -786,21 +776,19 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
self.emit('websocket:outgoing', req, socket, head, data);
var flushed = reverseProxy.incoming.socket.write(data);
if (!flushed) {
//console.error('backpressure 777');
proxySocket.pause();
reverseProxy.incoming.socket.once('drain', function () {
try {
proxySocket.resume();
} catch (er) {
console.error("proxySocket.resume error: %s", er.message);
}
try { proxySocket.resume() }
catch (er) { console.error("proxySocket.resume error: %s", er.message) }
});
setTimeout(function () {
reverseProxy.incoming.socket.emit('drain');
}, 100);
}
}
catch (e) {
catch (ex) {
detach();
reverseProxy.incoming.socket.end();
proxySocket.end();
......@@ -817,21 +805,19 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
self.emit('websocket:incoming', reverseProxy, reverseProxy.incoming, head, data);
var flushed = proxySocket.write(data);
if (!flushed) {
//console.error('backpressure 804');
reverseProxy.incoming.socket.pause();
proxySocket.once('drain', function () {
try {
reverseProxy.incoming.socket.resume();
} catch (er) {
console.error("reverseProxy.incoming.socket.resume error: %s", er.message);
}
try { reverseProxy.incoming.socket.resume() }
catch (ex) { console.error("reverseProxy.incoming.socket.resume error: %s", er.message) }
});
setTimeout(function () {
proxySocket.emit('drain');
}, 100);
}
}
catch (e) {
catch (ex) {
detach();
proxySocket.end();
socket.end();
......@@ -991,15 +977,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
socket.write(sdata);
var flushed = socket.write(data);
if (!flushed) {
//console.error('backpressure 974');
reverseProxy.socket.pause();
socket.once('drain', function () {
try {
reverseProxy.socket.resume();
} catch (er) {
console.error("reverseProxy.socket.resume error: %s", er.message);
}
try { reverseProxy.socket.resume() }
catch (er) { console.error("reverseProxy.socket.resume error: %s", er.message) }
});
setTimeout(function () {
socket.emit('drain');
}, 100);
......@@ -1007,7 +991,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
}
catch (ex) {
proxyError(ex)
proxyError(ex);
}
// Catch socket errors
......@@ -1034,7 +1018,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
if (options.buffer) {
if (!errState) {
options.buffer.resume();
} else {
}
else {
options.buffer.destroy();
}
}
......
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