Skip to content

Commit

Permalink
resume() can throw
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Sep 8, 2011
1 parent 37e2541 commit 0c71119
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/node-http-proxy/http-proxy.js
Expand Up @@ -238,7 +238,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
if (!flushed) {
response.pause();
res.once('drain', function () {
response.resume();
try { response.resume() }
catch (er) { console.error("response.resume error: %s", er.message) }
});

//
Expand Down Expand Up @@ -287,7 +288,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
if (!flushed) {
req.pause();
reverseProxy.once('drain', function () {
req.resume();
try { req.resume() }
catch (er) { console.error("req.resume error: %s", er.message) }
});

//
Expand Down Expand Up @@ -370,7 +372,8 @@ HttpProxy.prototype._forwardRequest = function (req) {
if (!flushed) {
req.pause();
forwardProxy.once('drain', function () {
req.resume();
try { req.resume() }
catch (er) { console.error("req.resume error: %s", er.message) }
});

//
Expand Down Expand Up @@ -470,7 +473,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
if (!flushed) {
proxySocket.pause();
reverseProxy.incoming.socket.once('drain', function () {
proxySocket.resume();
try { proxySocket.resume() }
catch (er) { console.error("proxySocket.resume error: %s", er.message) }
});

//
Expand Down Expand Up @@ -501,7 +505,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
if (!flushed) {
reverseProxy.incoming.socket.pause();
proxySocket.once('drain', function () {
reverseProxy.incoming.socket.resume();
try { reverseProxy.incoming.socket.resume() }
catch (er) { console.error("reverseProxy.incoming.socket.resume error: %s", er.message) }
});

//
Expand Down Expand Up @@ -619,7 +624,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// This will force us not to disconnect.
//
// In addition, it's important to note the closure scope here. Since
// there is no mapping of the
// there is no mapping of the socket to the request bound to it.
//
if (!agent._events || agent._events['upgrade'].length === 0) {
agent.on('upgrade', function (_, remoteSocket, head) {
Expand Down Expand Up @@ -673,7 +678,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
if (!flushed) {
reverseProxy.socket.pause();
socket.once('drain', function () {
reverseProxy.socket.resume();
try { reverseProxy.socket.resume() }
catch (er) { console.error("reverseProxy.socket.resume error: %s", er.message) }
});

//
Expand Down

0 comments on commit 0c71119

Please sign in to comment.