From 261742a4295268ef93f45aa0f1e3a04208a2aed3 Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Thu, 14 Aug 2014 17:16:56 -0400 Subject: [PATCH] [fix] cleanup and stylize close function --- lib/http-proxy/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index 0555e56..94b1849 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -135,18 +135,18 @@ ProxyServer.prototype.listen = function(port, hostname) { }; ProxyServer.prototype.close = function(callback) { + var self = this; if (this._server) { - // Wrap callback to nullify server after all open connections are closed. - var callback_wrapper = function() { - this._server = null; - - if (callback) { - callback(arguments); - } - }; - - this._server.close(callback_wrapper); + this._server.close(done); } + + // 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) {