2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Replacing 'agent' option with 'httpAgent' and 'httpsAgent'

This commit is contained in:
Rubén Norte
2016-07-22 21:09:54 +02:00
parent 0578445929
commit 4c790d5a7a
+7 -3
View File
@@ -61,13 +61,17 @@ module.exports = function httpAdapter(config) {
var urlPassword = urlAuth[1] || '';
auth = urlUsername + ':' + urlPassword;
}
var isHttps = parsed.protocol === 'https:';
var agent = isHttps ? config.httpsAgent : config.httpAgent;
var options = {
hostname: parsed.hostname,
port: parsed.port,
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
method: config.method,
headers: headers,
agent: config.agent,
agent: agent,
auth: auth
};
@@ -79,12 +83,12 @@ module.exports = function httpAdapter(config) {
var transport;
if (config.maxRedirects === 0) {
transport = parsed.protocol === 'https:' ? https : http;
transport = isHttps ? https : http;
} else {
if (config.maxRedirects) {
options.maxRedirects = config.maxRedirects;
}
transport = parsed.protocol === 'https:' ? httpsFollow : httpFollow;
transport = isHttps ? httpsFollow : httpFollow;
}
// Create the request