mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
update to 4.0
This commit is contained in:
17
rule_sample/sample_modify_request_header.js
Normal file
17
rule_sample/sample_modify_request_header.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
sample:
|
||||
modify the user-agent in requests toward httpbin.org
|
||||
test:
|
||||
curl http://httpbin.org/user-agent --proxy http://127.0.0.1:8001
|
||||
*/
|
||||
module.exports = {
|
||||
*beforeSendRequest(requestDetail) {
|
||||
if (requestDetail.url.indexOf('http://httpbin.org') === 0) {
|
||||
const newRequestOptions = requestDetail.requestOptions;
|
||||
newRequestOptions.headers['User-Agent'] = 'AnyProxy/0.0.0';
|
||||
return {
|
||||
requestOptions: newRequestOptions
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user