mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] always be an eventemitter for consistency fixes #606
This commit is contained in:
parent
7e5feec34f
commit
c6b7a7919f
@ -8,13 +8,6 @@ var http = require('http'),
|
|||||||
*/
|
*/
|
||||||
module.exports = httpProxy.Server;
|
module.exports = httpProxy.Server;
|
||||||
|
|
||||||
module.exports.createProxy = function(options) {
|
|
||||||
return {
|
|
||||||
web: httpProxy.createRightProxy('web')(options),
|
|
||||||
ws: httpProxy.createRightProxy('ws')(options)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the proxy server.
|
* Creates the proxy server.
|
||||||
*
|
*
|
||||||
@ -30,7 +23,9 @@ module.exports.createProxy = function(options) {
|
|||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports.createProxyServer = module.exports.createServer = function createProxyServer(options) {
|
module.exports.createProxyServer =
|
||||||
|
module.exports.createServer =
|
||||||
|
module.exports.createProxy = function createProxyServer(options) {
|
||||||
/*
|
/*
|
||||||
* `options` is needed and it must have the following layout:
|
* `options` is needed and it must have the following layout:
|
||||||
*
|
*
|
||||||
|
|||||||
@ -26,15 +26,10 @@ httpProxy.Server = ProxyServer;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function createRightProxy(type) {
|
function createRightProxy(type) {
|
||||||
var webPasses = Object.keys(web).map(function(pass) {
|
|
||||||
return web[pass];
|
|
||||||
});
|
|
||||||
var wsPasses = Object.keys(ws).map(function(pass) {
|
|
||||||
return ws[pass];
|
|
||||||
});
|
|
||||||
return function(options) {
|
return function(options) {
|
||||||
return function(req, res /*, [head], [opts] */) {
|
return function(req, res /*, [head], [opts] */) {
|
||||||
var passes = (type === 'ws') ? (this.wsPasses || wsPasses) : (this.webPasses || webPasses),
|
var passes = (type === 'ws') ? this.wsPasses : this.webPasses,
|
||||||
args = [].slice.call(arguments),
|
args = [].slice.call(arguments),
|
||||||
cntr = args.length - 1,
|
cntr = args.length - 1,
|
||||||
head, cbl;
|
head, cbl;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user