Merge branch 'supnate-master'

bugfix for proxy https server with a port other than 443
This commit is contained in:
OttoMao 2015-09-03 10:51:37 +08:00
commit 6146b23988

View File

@ -18,11 +18,17 @@ var defaultRule = require("./rule_default.js"),
userRule = defaultRule; //init userRule = defaultRule; //init
function userRequestHandler(req,userRes){ function userRequestHandler(req,userRes){
/*
note
req.url is wired
in http server : http://www.example.com/a/b/c
in https server : /a/b/c
*/
var host = req.headers.host, var host = req.headers.host,
urlPattern = url.parse(req.url),
path = urlPattern.path,
protocol = (!!req.connection.encrypted && !/^http:/.test(req.url)) ? "https" : "http", protocol = (!!req.connection.encrypted && !/^http:/.test(req.url)) ? "https" : "http",
fullUrl = protocol === "http" ? req.url : (protocol + '://' + host + req.url),
urlPattern = url.parse(fullUrl),
path = urlPattern.path,
resourceInfo, resourceInfo,
resourceInfoId = -1, resourceInfoId = -1,
reqData; reqData;
@ -417,10 +423,3 @@ module.exports.userRequestHandler = userRequestHandler;
module.exports.connectReqHandler = connectReqHandler; module.exports.connectReqHandler = connectReqHandler;
module.exports.setRules = setRules; module.exports.setRules = setRules;
module.exports.getRuleSummary = getRuleSummary; module.exports.getRuleSummary = getRuleSummary;
/*
note
req.url is wired
in http server : http://www.example.com/a/b/c
in https server : /a/b/c
*/