mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-22 15:21:26 +00:00
20 lines
651 B
JavaScript
20 lines
651 B
JavaScript
//rule scheme :
|
|
|
|
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!";
|
|
callback(newDataStr);
|
|
}else{
|
|
callback(serverResData);
|
|
}
|
|
|
|
}
|
|
};
|