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:
19
rule_sample/sample_modify_response_header.js
Normal file
19
rule_sample/sample_modify_response_header.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
sample:
|
||||
modify response header of http://httpbin.org/user-agent
|
||||
test:
|
||||
curl -I 'http://httpbin.org/user-agent' --proxy http://127.0.0.1:8001
|
||||
expected response:
|
||||
X-Proxy-By: AnyProxy
|
||||
*/
|
||||
module.exports = {
|
||||
*beforeSendResponse(requestDetail, responseDetail) {
|
||||
if (requestDetail.url.indexOf('http://httpbin.org/user-agent') === 0) {
|
||||
const newResponse = responseDetail.response;
|
||||
newResponse.header['X-Proxy-By'] = 'AnyProxy';
|
||||
return {
|
||||
response: newResponse
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user