Skip to content

Commit

Permalink
Do not rely on func.name (no scope)
Browse files Browse the repository at this point in the history
  • Loading branch information
131 authored and jcrugzz committed Oct 22, 2016
1 parent 61c2889 commit d48f67e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
19 changes: 8 additions & 11 deletions lib/http-proxy/passes/web-incoming.js
Original file line number Diff line number Diff line change
@@ -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];
Expand All @@ -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.
Expand All @@ -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';
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -168,7 +168,4 @@ web_o = Object.keys(web_o).map(function(pass) {
//proxyReq.end();
}

] // <--
.forEach(function(func) {
passes[func.name] = func;
});
};
18 changes: 6 additions & 12 deletions lib/http-proxy/passes/ws-incoming.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var http = require('http'),
https = require('https'),
common = require('../common'),
passes = exports;
common = require('../common');

/*!
* Array of passes.
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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 = {
Expand All @@ -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);
Expand Down Expand Up @@ -155,8 +153,4 @@ var passes = exports;
socket.end();
}
}

] // <--
.forEach(function(func) {
passes[func.name] = func;
});
};

0 comments on commit d48f67e

Please sign in to comment.