mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] Optimize fix for x-forwarded-for-port.
This commit is contained in:
parent
d4e91ebc33
commit
2d42709c32
@ -30,6 +30,13 @@ var events = require('events'),
|
|||||||
url = require('url'),
|
url = require('url'),
|
||||||
httpProxy = require('../node-http-proxy');
|
httpProxy = require('../node-http-proxy');
|
||||||
|
|
||||||
|
//
|
||||||
|
// @private {RegExp} extractPort
|
||||||
|
// Reusable regular expression for getting the
|
||||||
|
// port from a host string.
|
||||||
|
//
|
||||||
|
var extractPort = /:(\d+)$/;
|
||||||
|
|
||||||
//
|
//
|
||||||
// ### function HttpProxy (options)
|
// ### function HttpProxy (options)
|
||||||
// #### @options {Object} Options for this instance.
|
// #### @options {Object} Options for this instance.
|
||||||
@ -957,14 +964,12 @@ HttpProxy.prototype._forwardRequest = function (req) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getPortFromHostHeader(req) {
|
function getPortFromHostHeader(req) {
|
||||||
var portMatch = req.headers.host.match(/:(\d+)$/);
|
var match;
|
||||||
|
if ((match = extractPort.exec(req.headers.host))) {
|
||||||
|
return parseInt(match[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if(portMatch) {
|
return getProto(req) === 'https' ? 443 : 80;
|
||||||
return parseInt(portMatch[1]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return getProto(req) === 'https' ? 443 : 80;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProto(req) {
|
function getProto(req) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user