Skip to content

Commit

Permalink
[minor] Remove commented out debug statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Sep 8, 2011
1 parent 558a8a4 commit 5575bcf
Showing 1 changed file with 48 additions and 63 deletions.
111 changes: 48 additions & 63 deletions lib/node-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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) {
}
catch (er) {
console.error("res.write error: %s", er.message);
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;
}
}
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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -625,7 +616,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
if (options.buffer) {
if (!errState) {
options.buffer.resume();
} else {
}
else {
options.buffer.destroy();
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -991,23 +977,21 @@ 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);
}

}
catch (ex) {
proxyError(ex)
proxyError(ex);
}

// Catch socket errors
Expand All @@ -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();
}
}
Expand Down

0 comments on commit 5575bcf

Please sign in to comment.