Skip to content

Commit 261742a

Browse files
committed
[fix] cleanup and stylize close function
1 parent f92f7ae commit 261742a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/http-proxy/index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ ProxyServer.prototype.listen = function(port, hostname) {
135135
};
136136

137137
ProxyServer.prototype.close = function(callback) {
138+
var self = this;
138139
if (this._server) {
139-
// Wrap callback to nullify server after all open connections are closed.
140-
var callback_wrapper = function() {
141-
this._server = null;
142-
143-
if (callback) {
144-
callback(arguments);
145-
}
146-
};
147-
148-
this._server.close(callback_wrapper);
140+
this._server.close(done);
149141
}
142+
143+
// Wrap callback to nullify server after all open connections are closed.
144+
function done() {
145+
self._server = null;
146+
if (callback) {
147+
callback.apply(null, arguments);
148+
}
149+
};
150150
};
151151

152152
ProxyServer.prototype.before = function(type, passName, callback) {

0 commit comments

Comments
 (0)