Skip to content

Commit

Permalink
Update requestHandler.js
Browse files Browse the repository at this point in the history
enable rule.beforeDealHttpsRequest to overwrite host and port
  • Loading branch information
evlon authored Jul 9, 2021
1 parent b93f948 commit 855fb42
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/requestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ function getConnectReqHandler(userRule, recorder, httpsServerMgr) {
const reqHandlerCtx = this; reqHandlerCtx.conns = new Map(); reqHandlerCtx.cltSockets = new Map()

return function (req, cltSocket, head) {
const host = req.url.split(':')[0],
let host = req.url.split(':')[0],
targetPort = req.url.split(':')[1];
let shouldIntercept;
let interceptWsRequest = false;
Expand All @@ -552,7 +552,12 @@ function getConnectReqHandler(userRule, recorder, httpsServerMgr) {
// the return value in default rule is null
// so if the value is null, will take it as final value
shouldIntercept = yield userRule.beforeDealHttpsRequest(requestDetail);


//enable rule.beforeDealHttpsRequest to overwrite host and port @evlon 2021-7-9
if(requestDetail.host != req.url){
host = requestDetail.host.split(':')[0],
targetPort = requestDetail.host.split(':')[1];
}
// otherwise, will take the passed in option
if (shouldIntercept === null) {
shouldIntercept = reqHandlerCtx.forceProxyHttps;
Expand Down

0 comments on commit 855fb42

Please sign in to comment.