mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[api] Added new close() method which cleans up sockets from HttpProxy instances
This commit is contained in:
parent
ec03d72c5d
commit
0eae2a913a
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user