@@ -13,6 +13,8 @@ var pkg = require('./../../package.json');
13
13
var createError = require ( '../core/createError' ) ;
14
14
var enhanceError = require ( '../core/enhanceError' ) ;
15
15
16
+ var isHttps = / h t t p s : ? / ;
17
+
16
18
/*eslint consistent-return:0*/
17
19
module . exports = function httpAdapter ( config ) {
18
20
return new Promise ( function dispatchHttpRequest ( resolvePromise , rejectPromise ) {
@@ -76,8 +78,8 @@ module.exports = function httpAdapter(config) {
76
78
delete headers . Authorization ;
77
79
}
78
80
79
- var isHttps = protocol === 'https:' ;
80
- var agent = isHttps ? config . httpsAgent : config . httpAgent ;
81
+ var isHttpsRequest = isHttps . test ( protocol ) ;
82
+ var agent = isHttpsRequest ? config . httpsAgent : config . httpAgent ;
81
83
82
84
var options = {
83
85
path : buildURL ( parsed . path , config . params , config . paramsSerializer ) . replace ( / ^ \? / , '' ) ,
@@ -130,15 +132,16 @@ module.exports = function httpAdapter(config) {
130
132
}
131
133
132
134
var transport ;
135
+ var isHttpsProxy = isHttpsRequest && ( proxy ? isHttps . test ( proxy . protocol ) : true ) ;
133
136
if ( config . transport ) {
134
137
transport = config . transport ;
135
138
} else if ( config . maxRedirects === 0 ) {
136
- transport = isHttps ? https : http ;
139
+ transport = isHttpsProxy ? https : http ;
137
140
} else {
138
141
if ( config . maxRedirects ) {
139
142
options . maxRedirects = config . maxRedirects ;
140
143
}
141
- transport = isHttps ? httpsFollow : httpFollow ;
144
+ transport = isHttpsProxy ? httpsFollow : httpFollow ;
142
145
}
143
146
144
147
if ( config . maxContentLength && config . maxContentLength > - 1 ) {
0 commit comments