diff --git a/lib/request_urls.js b/lib/request_urls.js index 1df09ac..79919bc 100644 --- a/lib/request_urls.js +++ b/lib/request_urls.js @@ -1,4 +1,5 @@ var http = require('http'); +var https = require('https'); var request = require('request'); var ExponentialBackoff = require( '../lib/ExponentialBackoff'); @@ -28,7 +29,8 @@ function shouldRetryRequest(res) { function request_urls(urls, callback) { var total_length = urls.length; var responses = {}; - var agent = new http.Agent({keepAlive: true, maxSockets: 1}); + var httpAgent = new http.Agent({keepAlive: true, maxSockets: 1}); + var httpsAgent = new https.Agent({keepAlive: true, maxSockets: 1}); var intervalId; var test_interval = new ExponentialBackoff(1, 5, 1, 20000); var delay = test_interval.getBackoff(); @@ -40,6 +42,8 @@ function request_urls(urls, callback) { var url = urls.pop(); + const agent = (url.startsWith('https:')) ? httpsAgent : httpAgent; + var requestOpts = { headers: {'user-agent': 'pelias-fuzzy-tester'}, url: url,