Skip to content

Commit

Permalink
fixed request
Browse files Browse the repository at this point in the history
  • Loading branch information
da1nerd committed Mar 13, 2019
1 parent 9de6b7c commit 18f5183
Show file tree
Hide file tree
Showing 3 changed files with 4,953 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ var https = require('https');
var http = require('http');
var fs = require('fs');
var rimraf = require('rimraf');
var HttpAgent = require('agentkeepalive');
var HttpsAgent = require('agentkeepalive').HttpsAgent;

var httpAgent = new HttpAgent();
var httpsAgent = new HttpsAgent();
const timeout = 30000;
const agentOptions = {
keepAlive: true,
timeout
};
var httpAgent = new http.Agent(agentOptions);
var httpsAgent = new https.Agent(agentOptions);

/**
* Reads the contents of a url as a string.
Expand Down Expand Up @@ -48,9 +51,6 @@ function read(uri) {
});
});

req.on('socket', function(socket) {
socket.setTimeout(30000);
});
req.on('error', reject);
req.end();
});
Expand Down Expand Up @@ -111,4 +111,4 @@ function download(uri, dest, progressCallback) {
}

module.exports.read = read;
module.exports.download = download;
module.exports.download = download;
Loading

0 comments on commit 18f5183

Please sign in to comment.