feat: refact requestHandler into TS

This commit is contained in:
砚然
2018-08-28 11:59:43 +08:00
parent 51abd0532c
commit 201447a19a
21 changed files with 741 additions and 559 deletions

View File

@@ -9,14 +9,19 @@
module.exports = {
*beforeSendRequest(requestDetail) {
if (requestDetail.url.indexOf('https://httpbin.org/user-agent') === 0) {
console.info(requestDetail._req.connection._peername);
const newRequestOptions = requestDetail.requestOptions;
requestDetail.protocol = 'http';
requestDetail.protocol = 'https';
newRequestOptions.hostname = '127.0.0.1'
newRequestOptions.port = '8008';
newRequestOptions.path = '/index.html';
newRequestOptions.port = '3001';
newRequestOptions.path = '/test';
newRequestOptions.method = 'GET';
return requestDetail;
}
if (requestDetail.url.indexOf('http://mobilegw.stable.alipay.net/mgw.htm') === 0) {
console.info(requestDetail.requestData.toString())
}
},
*beforeDealHttpsRequest(requestDetail) {
return true;