[api] Added new close() method which cleans up sockets from HttpProxy instances

This commit is contained in:
indexzero 2011-09-08 16:55:45 -07:00
parent ec03d72c5d
commit 0eae2a913a

View File

@ -662,6 +662,21 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
}
};
//
// ### function close()
// Closes all sockets associated with the Agents
// belonging to this instance.
//
HttpProxy.prototype.close = function () {
[this.forward, this.target].forEach(function (proxy) {
if (proxy.agent) {
proxy.agent.sockets.forEach(function (socket) {
socket.end();
});
}
});
};
//
// ### @private function _forwardRequest (req)
// #### @req {ServerRequest} Incoming HTTP Request to proxy.