Skip to content

Commit d48f67e

Browse files
131jcrugzz
authored andcommitted
Do not rely on func.name (no scope)
1 parent 61c2889 commit d48f67e

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

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

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
var http = require('http'),
22
https = require('https'),
33
web_o = require('./web-outgoing'),
4-
common = require('../common'),
5-
passes = exports;
4+
common = require('../common');
65

76
web_o = Object.keys(web_o).map(function(pass) {
87
return web_o[pass];
@@ -16,7 +15,8 @@ web_o = Object.keys(web_o).map(function(pass) {
1615
* flexible.
1716
*/
1817

19-
[ // <--
18+
19+
module.exports = {
2020

2121
/**
2222
* Sets `content-length` to '0' if request is of DELETE type.
@@ -28,7 +28,7 @@ web_o = Object.keys(web_o).map(function(pass) {
2828
* @api private
2929
*/
3030

31-
function deleteLength(req, res, options) {
31+
deleteLength : function(req, res, options) {
3232
if((req.method === 'DELETE' || req.method === 'OPTIONS')
3333
&& !req.headers['content-length']) {
3434
req.headers['content-length'] = '0';
@@ -46,7 +46,7 @@ web_o = Object.keys(web_o).map(function(pass) {
4646
* @api private
4747
*/
4848

49-
function timeout(req, res, options) {
49+
timeout: function(req, res, options) {
5050
if(options.timeout) {
5151
req.socket.setTimeout(options.timeout);
5252
}
@@ -62,7 +62,7 @@ web_o = Object.keys(web_o).map(function(pass) {
6262
* @api private
6363
*/
6464

65-
function XHeaders(req, res, options) {
65+
XHeaders : function(req, res, options) {
6666
if(!options.xfwd) return;
6767

6868
var encrypted = req.isSpdy || common.hasEncryptedConnection(req);
@@ -94,7 +94,7 @@ web_o = Object.keys(web_o).map(function(pass) {
9494
* @api private
9595
*/
9696

97-
function stream(req, res, options, _, server, clb) {
97+
stream : function(req, res, options, _, server, clb) {
9898

9999
// And we begin!
100100
server.emit('start', req, res, options.target)
@@ -168,7 +168,4 @@ web_o = Object.keys(web_o).map(function(pass) {
168168
//proxyReq.end();
169169
}
170170

171-
] // <--
172-
.forEach(function(func) {
173-
passes[func.name] = func;
174-
});
171+
};

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

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var http = require('http'),
22
https = require('https'),
3-
common = require('../common'),
4-
passes = exports;
3+
common = require('../common');
54

65
/*!
76
* Array of passes.
@@ -16,9 +15,8 @@ var http = require('http'),
1615
*
1716
*/
1817

19-
var passes = exports;
2018

21-
[
19+
module.exports = {
2220
/**
2321
* WebSocket requests must have the `GET` method and
2422
* the `upgrade:websocket` header
@@ -29,7 +27,7 @@ var passes = exports;
2927
* @api private
3028
*/
3129

32-
function checkMethodAndHeader (req, socket) {
30+
checkMethodAndHeader : function (req, socket) {
3331
if (req.method !== 'GET' || !req.headers.upgrade) {
3432
socket.destroy();
3533
return true;
@@ -51,7 +49,7 @@ var passes = exports;
5149
* @api private
5250
*/
5351

54-
function XHeaders(req, socket, options) {
52+
XHeaders : function(req, socket, options) {
5553
if(!options.xfwd) return;
5654

5755
var values = {
@@ -78,7 +76,7 @@ var passes = exports;
7876
*
7977
* @api private
8078
*/
81-
function stream(req, socket, options, head, server, clb) {
79+
stream : function(req, socket, options, head, server, clb) {
8280
common.setupSocket(socket);
8381

8482
if (head && head.length) socket.unshift(head);
@@ -155,8 +153,4 @@ var passes = exports;
155153
socket.end();
156154
}
157155
}
158-
159-
] // <--
160-
.forEach(function(func) {
161-
passes[func.name] = func;
162-
});
156+
};

0 commit comments

Comments
 (0)