mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
commit
d4942e52e7
@ -8,6 +8,13 @@ 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.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -80,7 +80,7 @@ function createRightProxy(type) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
httpProxy.createRightProxy = createRightProxy;
|
||||||
|
|
||||||
function ProxyServer(options) {
|
function ProxyServer(options) {
|
||||||
EE3.call(this);
|
EE3.call(this);
|
||||||
@ -96,6 +96,10 @@ function ProxyServer(options) {
|
|||||||
this.wsPasses = Object.keys(ws).map(function(pass) {
|
this.wsPasses = Object.keys(ws).map(function(pass) {
|
||||||
return ws[pass];
|
return ws[pass];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.on('error', function(err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
require('util').inherits(ProxyServer, EE3);
|
require('util').inherits(ProxyServer, EE3);
|
||||||
|
|||||||
@ -117,7 +117,7 @@ web_o = Object.keys(web_o).map(function(pass) {
|
|||||||
(options.buffer || req).pipe(proxyReq);
|
(options.buffer || req).pipe(proxyReq);
|
||||||
|
|
||||||
proxyReq.on('response', function(proxyRes) {
|
proxyReq.on('response', function(proxyRes) {
|
||||||
server.emit('proxyRes', proxyRes);
|
if(server) { server.emit('proxyRes', proxyRes); }
|
||||||
for(var i=0; i < web_o.length; i++) {
|
for(var i=0; i < web_o.length; i++) {
|
||||||
if(web_o[i](req, res, proxyRes)) { break; }
|
if(web_o[i](req, res, proxyRes)) { break; }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user