Skip to content

Commit 68bfa4d

Browse files
committed
Proxy request changed to use only HTTP_PROXY and HTTPS_PROXY
1 parent aab2470 commit 68bfa4d

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

openid-request.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,10 @@ var _buildUrl = function(theUrl, params)
160160
var _proxyRequest = function(protocol, options)
161161
{
162162
/*
163-
If process.env['HTTP_PROXY_HOST'] and the env variable `HTTP_PROXY_POST`
164-
are set, make sure path and the header Host are set to target url.
165-
166-
Similarly, `HTTPS_PROXY_HOST` and `HTTPS_PROXY_PORT` can be used
167-
to proxy HTTPS traffic.
168-
163+
Set this ENV vars on your system for PROXY request.
169164
Proxies Example:
170-
export HTTP_PROXY_HOST=localhost
171-
export HTTP_PROXY_PORT=8080
172-
export HTTPS_PROXY_HOST=localhost
173-
export HTTPS_PROXY_PORT=8442
165+
export HTTP_PROXY=http://localhost:8080
166+
export HTTPS_PROXY=https://localhost:8080
174167
175168
Function returns protocol which should be used for network request, one of
176169
http: or https:
@@ -179,25 +172,21 @@ var _proxyRequest = function(protocol, options)
179172
var newProtocol = protocol;
180173
if (!targetHost) return;
181174
var updateOptions = function (envPrefix) {
182-
var proxyHostname = process.env[envPrefix + '_PROXY_HOST'].trim();
183-
var proxyPort = parseInt(process.env[envPrefix + '_PROXY_PORT'], 10);
184-
if (proxyHostname.length > 0 && ! isNaN(proxyPort)) {
175+
var proxy = process.env[envPrefix + '_PROXY'].trim();
176+
if (proxy.length > 0) {
185177
if (! options.headers) options.headers = {};
186178

187-
var targetHostAndPort = (isNaN(options.port) || (options.port === null)) ? targetHost : targetHost + ':' + options.port;
188-
options.headers['Host'] = targetHostAndPort;
189-
options.proxy = proxyHostname + ':' + proxyPort;
179+
options.headers['Host'] = targetHost;
180+
options.proxy = proxy;
190181
}
191182
};
192183
if ('https:' === protocol &&
193-
!! process.env['HTTPS_PROXY_HOST'] &&
194-
!! process.env['HTTPS_PROXY_PORT']) {
184+
!! process.env['HTTPS_PROXY']) {
195185
updateOptions('HTTPS');
196186
// Proxy server request must be done via http... it is responsible for
197187
// Making the https request...
198188
newProtocol = 'http:';
199-
} else if (!! process.env['HTTP_PROXY_HOST'] &&
200-
!! process.env['HTTP_PROXY_PORT']) {
189+
} else if (!! process.env['HTTP_PROXY']) {
201190
updateOptions('HTTP');
202191
}
203192
return newProtocol;

0 commit comments

Comments
 (0)