Do not rely on func.name (no scope)

This commit is contained in:
François Leurent 2016-09-20 15:32:14 +02:00 committed by Jarrett Cruger
parent 61c2889109
commit d48f67eb90
2 changed files with 14 additions and 23 deletions

View File

@ -1,8 +1,7 @@
var http = require('http'),
https = require('https'),
web_o = require('./web-outgoing'),
common = require('../common'),
passes = exports;
common = require('../common');
web_o = Object.keys(web_o).map(function(pass) {
return web_o[pass];
@ -16,7 +15,8 @@ web_o = Object.keys(web_o).map(function(pass) {
* flexible.
*/
[ // <--
module.exports = {
/**
* Sets `content-length` to '0' if request is of DELETE type.
@ -28,7 +28,7 @@ web_o = Object.keys(web_o).map(function(pass) {
* @api private
*/
function deleteLength(req, res, options) {
deleteLength : function(req, res, options) {
if((req.method === 'DELETE' || req.method === 'OPTIONS')
&& !req.headers['content-length']) {
req.headers['content-length'] = '0';
@ -46,7 +46,7 @@ web_o = Object.keys(web_o).map(function(pass) {
* @api private
*/
function timeout(req, res, options) {
timeout: function(req, res, options) {
if(options.timeout) {
req.socket.setTimeout(options.timeout);
}
@ -62,7 +62,7 @@ web_o = Object.keys(web_o).map(function(pass) {
* @api private
*/
function XHeaders(req, res, options) {
XHeaders : function(req, res, options) {
if(!options.xfwd) return;
var encrypted = req.isSpdy || common.hasEncryptedConnection(req);
@ -94,7 +94,7 @@ web_o = Object.keys(web_o).map(function(pass) {
* @api private
*/
function stream(req, res, options, _, server, clb) {
stream : function(req, res, options, _, server, clb) {
// And we begin!
server.emit('start', req, res, options.target)
@ -168,7 +168,4 @@ web_o = Object.keys(web_o).map(function(pass) {
//proxyReq.end();
}
] // <--
.forEach(function(func) {
passes[func.name] = func;
});
};

View File

@ -1,7 +1,6 @@
var http = require('http'),
https = require('https'),
common = require('../common'),
passes = exports;
common = require('../common');
/*!
* Array of passes.
@ -16,9 +15,8 @@ var http = require('http'),
*
*/
var passes = exports;
[
module.exports = {
/**
* WebSocket requests must have the `GET` method and
* the `upgrade:websocket` header
@ -29,7 +27,7 @@ var passes = exports;
* @api private
*/
function checkMethodAndHeader (req, socket) {
checkMethodAndHeader : function (req, socket) {
if (req.method !== 'GET' || !req.headers.upgrade) {
socket.destroy();
return true;
@ -51,7 +49,7 @@ var passes = exports;
* @api private
*/
function XHeaders(req, socket, options) {
XHeaders : function(req, socket, options) {
if(!options.xfwd) return;
var values = {
@ -78,7 +76,7 @@ var passes = exports;
*
* @api private
*/
function stream(req, socket, options, head, server, clb) {
stream : function(req, socket, options, head, server, clb) {
common.setupSocket(socket);
if (head && head.length) socket.unshift(head);
@ -155,8 +153,4 @@ var passes = exports;
socket.end();
}
}
] // <--
.forEach(function(func) {
passes[func.name] = func;
});
};