mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-22 23:31:25 +00:00
18 lines
482 B
JavaScript
18 lines
482 B
JavaScript
/*
|
|
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
|
|
};
|
|
}
|
|
},
|
|
};
|