Skip to content

Commit

Permalink
fix: Merge pull request #153 from adefarge/enable_https
Browse files Browse the repository at this point in the history
[fix] allow https endpoints
  • Loading branch information
orangejulius authored Jul 9, 2018
2 parents aeec1e0 + e5d395b commit 44f4375
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/request_urls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var http = require('http');
var https = require('https');
var request = require('request');

var ExponentialBackoff = require( '../lib/ExponentialBackoff');
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand Down

0 comments on commit 44f4375

Please sign in to comment.