mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] cleanup and stylize close function
This commit is contained in:
parent
f92f7aea9b
commit
261742a429
@ -135,18 +135,18 @@ ProxyServer.prototype.listen = function(port, hostname) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ProxyServer.prototype.close = function(callback) {
|
ProxyServer.prototype.close = function(callback) {
|
||||||
|
var self = this;
|
||||||
if (this._server) {
|
if (this._server) {
|
||||||
// Wrap callback to nullify server after all open connections are closed.
|
this._server.close(done);
|
||||||
var callback_wrapper = function() {
|
|
||||||
this._server = null;
|
|
||||||
|
|
||||||
if (callback) {
|
|
||||||
callback(arguments);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this._server.close(callback_wrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wrap callback to nullify server after all open connections are closed.
|
||||||
|
function done() {
|
||||||
|
self._server = null;
|
||||||
|
if (callback) {
|
||||||
|
callback.apply(null, arguments);
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
ProxyServer.prototype.before = function(type, passName, callback) {
|
ProxyServer.prototype.before = function(type, passName, callback) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user