Skip to content

Commit

Permalink
Merge pull request #137 from tonytamps/devel
Browse files Browse the repository at this point in the history
Use the same proxy and jar for fetchUrl
  • Loading branch information
macbre authored Nov 10, 2017
2 parents a5569a6 + 1561ff0 commit 2eb9bcf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,18 @@ module.exports = (function() {
this.queue.push(function(done) {
self.info("Fetching <%s> (as %s)...", url, encoding);

request({
const options = {
url,
encoding: (encoding === 'binary') ? null : encoding
}, function (error, response, body) {
method: 'GET',
proxy: self.proxy || false,
jar: self.jar,
encoding: (encoding === 'binary') ? null : encoding,
headers: {
'User-Agent': self.userAgent
}
};

request(options, function (error, response, body) {
if (!error && response.statusCode === 200) {
self.info('<%s>: fetched %s kB', url, (body.length/1024).toFixed(2));
callback(null, body);
Expand Down

0 comments on commit 2eb9bcf

Please sign in to comment.