From 5e130de8548ad41b821da49299b4fd1c9536c5f0 Mon Sep 17 00:00:00 2001 From: cronopio Date: Mon, 21 Oct 2013 14:49:39 -0500 Subject: [PATCH] Revert "[fix] fixed passes functions, now 'this' can be used and options are stored on 'this.options'" This reverts commit 9b3e1eb247df29d18ea299ff4ebb2f10eeb71269. --- lib/http-proxy/passes/ws-incoming.js | 9 ++++----- test/lib-http-proxy-test.js | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/http-proxy/passes/ws-incoming.js b/lib/http-proxy/passes/ws-incoming.js index 3e715c9..66c75d5 100644 --- a/lib/http-proxy/passes/ws-incoming.js +++ b/lib/http-proxy/passes/ws-incoming.js @@ -64,13 +64,12 @@ var passes = exports; * * @param {ClientRequest} Req Request object * @param {Socket} Websocket + * @param {Object} Options Config object passed to the proxy * * @api private */ - function XHeaders(req, socket) { - // Now the options are stored on this - var options = this.options; + function XHeaders(req, socket, options) { if(!options.xfwd) return; var values = { @@ -93,11 +92,11 @@ var passes = exports; * * @param {ClientRequest} Req Request object * @param {Socket} Websocket + * @param {Object} Options Config object passed to the proxy * * @api private */ - function stream(req, socket, head, clb) { - var server = this; + function stream(req, socket, server, head, clb) { common.setupSocket(socket); if (head && head.length) socket.unshift(head); diff --git a/test/lib-http-proxy-test.js b/test/lib-http-proxy-test.js index a74276e..73ee113 100644 --- a/test/lib-http-proxy-test.js +++ b/test/lib-http-proxy-test.js @@ -122,7 +122,7 @@ describe('lib/http-proxy.js', function() { proxy.on('error', function (err) { expect(err).to.be.an(Error); expect(err.code).to.be('ECONNREFUSED'); - proxy._server.close(); + proxyServer._server.close(); done(); }) @@ -148,7 +148,9 @@ describe('lib/http-proxy.js', function() { setTimeout(function () { res.end('At this point the socket should be closed'); }, 5) - }).listen('8080'); + }); + + source.listen('8080'); var testReq = http.request({ hostname: '127.0.0.1', @@ -159,8 +161,6 @@ describe('lib/http-proxy.js', function() { testReq.on('error', function (e) { expect(e).to.be.an(Error); expect(e.code).to.be.eql('ECONNRESET'); - proxy._server.close(); - source.close(); done(); });