@@ -160,17 +160,10 @@ var _buildUrl = function(theUrl, params)
160
160
var _proxyRequest = function ( protocol , options )
161
161
{
162
162
/*
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.
169
164
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
174
167
175
168
Function returns protocol which should be used for network request, one of
176
169
http: or https:
@@ -179,25 +172,21 @@ var _proxyRequest = function(protocol, options)
179
172
var newProtocol = protocol ;
180
173
if ( ! targetHost ) return ;
181
174
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 ) {
185
177
if ( ! options . headers ) options . headers = { } ;
186
178
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 ;
190
181
}
191
182
} ;
192
183
if ( 'https:' === protocol &&
193
- ! ! process . env [ 'HTTPS_PROXY_HOST' ] &&
194
- ! ! process . env [ 'HTTPS_PROXY_PORT' ] ) {
184
+ ! ! process . env [ 'HTTPS_PROXY' ] ) {
195
185
updateOptions ( 'HTTPS' ) ;
196
186
// Proxy server request must be done via http... it is responsible for
197
187
// Making the https request...
198
188
newProtocol = 'http:' ;
199
- } else if ( ! ! process . env [ 'HTTP_PROXY_HOST' ] &&
200
- ! ! process . env [ 'HTTP_PROXY_PORT' ] ) {
189
+ } else if ( ! ! process . env [ 'HTTP_PROXY' ] ) {
201
190
updateOptions ( 'HTTP' ) ;
202
191
}
203
192
return newProtocol ;
0 commit comments