mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-24 08:41:31 +00:00
Merge branch 'master' into optimize_web_server
This commit is contained in:
commit
d25a8a2274
@ -116,7 +116,7 @@ var options = {
|
||||
webConfigPort : 8088, // optional, internal port for web config(beta), replace this when it is conflict with your own service
|
||||
throttle : 10, // optional, speed limit in kb/s
|
||||
disableWebInterface : false, //optional, set it when you don't want to use the web interface
|
||||
silent : false, //optional, do not print anything into terminal. do not set it when you are still debugging.
|
||||
silent : false //optional, do not print anything into terminal. do not set it when you are still debugging.
|
||||
};
|
||||
new proxy.proxyServer(options);
|
||||
|
||||
|
7
proxy.js
7
proxy.js
@ -51,12 +51,7 @@ try{
|
||||
if(fs.existsSync(path.join(process.cwd(),'rule.js'))){
|
||||
default_rule = require(path.join(process.cwd(),'rule'));
|
||||
}
|
||||
}catch(e){
|
||||
if(e){
|
||||
logUtil.printLog("error" + e, logUtil.T_ERR);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}catch(e){}
|
||||
|
||||
//option
|
||||
//option.type : 'http'(default) or 'https'
|
||||
|
@ -98,7 +98,7 @@ module.exports = {
|
||||
//替换服务器响应的数据
|
||||
//replace the response from the server before it's sent to the user
|
||||
//you may return either a Buffer or a string
|
||||
//serverResData is a Buffer, you may get its content by calling serverResData.toString()
|
||||
//serverResData is a Buffer. for those non-unicode reponse , serverResData.toString() should not be your first choice.
|
||||
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
||||
callback(serverResData);
|
||||
},
|
||||
|
@ -4,6 +4,9 @@ module.exports = {
|
||||
|
||||
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
||||
//append "hello world" to all web pages
|
||||
|
||||
//for those non-unicode response , serverResData.toString() should not be your first choice.
|
||||
//this issue may help you understanding how to modify an non-unicode response: https://github.com/alibaba/anyproxy/issues/20
|
||||
if(/html/i.test(res.headers['content-type'])){
|
||||
var newDataStr = serverResData.toString();
|
||||
newDataStr += "hello world!";
|
||||
|
Loading…
x
Reference in New Issue
Block a user