diff --git a/README.md b/README.md index 122e74d..52602f9 100644 --- a/README.md +++ b/README.md @@ -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); diff --git a/proxy.js b/proxy.js index 9108405..30cd9d8 100644 --- a/proxy.js +++ b/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' diff --git a/rule_sample/rule__blank.js b/rule_sample/rule__blank.js index 1aadb15..192ae2c 100644 --- a/rule_sample/rule__blank.js +++ b/rule_sample/rule__blank.js @@ -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); }, diff --git a/rule_sample/rule_replace_response_data.js b/rule_sample/rule_replace_response_data.js index c049ac6..a8ffbe2 100644 --- a/rule_sample/rule_replace_response_data.js +++ b/rule_sample/rule_replace_response_data.js @@ -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!";