From 4c790d5a7a7df7a11e094a431a00e64bff65a19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Fri, 22 Jul 2016 21:09:54 +0200 Subject: [PATCH] Replacing 'agent' option with 'httpAgent' and 'httpsAgent' --- lib/adapters/http.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 959bed9..21b02ae 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -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