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_statuscode.js
Normal file
19
rule_sample/sample_modify_response_statuscode.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
sample:
|
||||
modify all status code of http://httpbin.org/ to 404
|
||||
test:
|
||||
curl -I 'http://httpbin.org/user-agent' --proxy http://127.0.0.1:8001
|
||||
expected response:
|
||||
HTTP/1.1 404 Not Found
|
||||
*/
|
||||
module.exports = {
|
||||
*beforeSendResponse(requestDetail, responseDetail) {
|
||||
if (requestDetail.url.indexOf('http://httpbin.org') === 0) {
|
||||
const newResponse = responseDetail.response;
|
||||
newResponse.statusCode = 404;
|
||||
return {
|
||||
response: newResponse
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user