diff --git a/lib/http.js b/lib/http.js index 6931a0e26c138a..bba0fec9fd8652 100644 --- a/lib/http.js +++ b/lib/http.js @@ -23,6 +23,7 @@ const client = require('_http_client'); const ClientRequest = exports.ClientRequest = client.ClientRequest; exports.request = function request(options, cb) { + options._defaultAgent = options._defaultAgent || exports.globalAgent || agent.globalAgent; return new ClientRequest(options, cb); }; diff --git a/lib/https.js b/lib/https.js index b8969b68452451..96ed03ba35e8fe 100644 --- a/lib/https.js +++ b/lib/https.js @@ -195,7 +195,7 @@ exports.request = function(options, cb) { } else { options = util._extend({}, options); } - options._defaultAgent = globalAgent; + options._defaultAgent = exports.globalAgent || globalAgent; return http.request(options, cb); };