mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-05-10 14:58:27 +00:00
add some tip in rules about non-unicode response
This commit is contained in:
parent
e98295379b
commit
66b3b86a12
@ -98,7 +98,7 @@ module.exports = {
|
|||||||
//替换服务器响应的数据
|
//替换服务器响应的数据
|
||||||
//replace the response from the server before it's sent to the user
|
//replace the response from the server before it's sent to the user
|
||||||
//you may return either a Buffer or a string
|
//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){
|
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
||||||
callback(serverResData);
|
callback(serverResData);
|
||||||
},
|
},
|
||||||
|
@ -4,6 +4,9 @@ module.exports = {
|
|||||||
|
|
||||||
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
||||||
//append "hello world" to all web pages
|
//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'])){
|
if(/html/i.test(res.headers['content-type'])){
|
||||||
var newDataStr = serverResData.toString();
|
var newDataStr = serverResData.toString();
|
||||||
newDataStr += "hello world!";
|
newDataStr += "hello world!";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user