Skip to content

Commit 5e130de

Browse files
committed
Revert "[fix] fixed passes functions, now 'this' can be used and options are stored on 'this.options'"
This reverts commit 9b3e1eb.
1 parent babdf53 commit 5e130de

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/http-proxy/passes/ws-incoming.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@ var passes = exports;
6464
*
6565
* @param {ClientRequest} Req Request object
6666
* @param {Socket} Websocket
67+
* @param {Object} Options Config object passed to the proxy
6768
*
6869
* @api private
6970
*/
7071

71-
function XHeaders(req, socket) {
72-
// Now the options are stored on this
73-
var options = this.options;
72+
function XHeaders(req, socket, options) {
7473
if(!options.xfwd) return;
7574

7675
var values = {
@@ -93,11 +92,11 @@ var passes = exports;
9392
*
9493
* @param {ClientRequest} Req Request object
9594
* @param {Socket} Websocket
95+
* @param {Object} Options Config object passed to the proxy
9696
*
9797
* @api private
9898
*/
99-
function stream(req, socket, head, clb) {
100-
var server = this;
99+
function stream(req, socket, server, head, clb) {
101100
common.setupSocket(socket);
102101

103102
if (head && head.length) socket.unshift(head);

test/lib-http-proxy-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('lib/http-proxy.js', function() {
122122
proxy.on('error', function (err) {
123123
expect(err).to.be.an(Error);
124124
expect(err.code).to.be('ECONNREFUSED');
125-
proxy._server.close();
125+
proxyServer._server.close();
126126
done();
127127
})
128128

@@ -148,7 +148,9 @@ describe('lib/http-proxy.js', function() {
148148
setTimeout(function () {
149149
res.end('At this point the socket should be closed');
150150
}, 5)
151-
}).listen('8080');
151+
});
152+
153+
source.listen('8080');
152154

153155
var testReq = http.request({
154156
hostname: '127.0.0.1',
@@ -159,8 +161,6 @@ describe('lib/http-proxy.js', function() {
159161
testReq.on('error', function (e) {
160162
expect(e).to.be.an(Error);
161163
expect(e.code).to.be.eql('ECONNRESET');
162-
proxy._server.close();
163-
source.close();
164164
done();
165165
});
166166

0 commit comments

Comments
 (0)