update doc

This commit is contained in:
加里
2014-09-03 15:20:57 +08:00
parent c5624a3c6b
commit e38d5fe7b1
4 changed files with 28 additions and 27 deletions

View File

@@ -1,12 +0,0 @@
## rule files sample
* **rule__blank.js**, blank rule file with some comments. You may read this before writing your own rule file.
* **rule_adjust_response_time.js**, delay all the response for 1500ms
* **rule_allow_CORS.js**, add CORS headers to allow cross-domain ajax request
* **rule_intercept_some_https_requests.js**, intercept https requests toward github.com
* **rule_remove_cache_header.js**, remove all cache-related headers from server
* **rule_replace_request_option.js**, replace request parameters before sending to the server
* **rule_replace_response_data.js**, modify response data
* **rule_replace_response_status_code.js**, replace server's status code
* **rule_use_local_data.js**, map some requests to local file

View File

@@ -6,11 +6,7 @@ module.exports = {
//whether to intercept this request by local logic
//if the return value is true, anyproxy will call dealLocalResponse to get response data and will not send request to remote server anymore
shouldUseLocalResponse : function(req,reqBody){
if(/hello/.test(reqBody.toString())){
return true;
}else{
return false;
}
return false;
},
//you may deal the response locally instead of sending it to server

View File

@@ -1,6 +1,14 @@
//rule scheme :
module.exports = {
replaceRequestOption : function(req,option){
var newOption = option;
delete newOption.headers['if-none-match'];
delete newOption.headers['if-modified-since'];
return newOption;
},
replaceResponseHeader: function(req,res,header){
header = header || {};
header["Cache-Control"] = "no-cache, no-store, must-revalidate";