Skip to content

Commit

Permalink
fix(downloader): fix against working proxy (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnishina authored and heathkit committed Aug 24, 2016
1 parent 7ec082a commit fa48354
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions lib/files/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,35 @@ export class Downloader {
let file = fs.createWriteStream(filePath);
let contentLength = 0;

if (opt_ignoreSSL) {
logger.info('ignoring SSL certificate');
interface Options {
url: string;
timeout: number;
strictSSL?: boolean;
rejectUnauthorized?: boolean;
proxy?: string;
headers?: {[key: string]: any};
[key: string]: any;
}

let options = {
let options: Options = {
url: fileUrl,
strictSSL: !opt_ignoreSSL,
rejectUnauthorized: !opt_ignoreSSL,
proxy: Downloader.resolveProxy_(fileUrl, opt_proxy),
// default Linux can be anywhere from 20-120 seconds
// increasing this arbitrarily to 4 minutes
timeout: 240000
};
}

if (opt_ignoreSSL) {
logger.info('ignoring SSL certificate');
options.strictSSL = !opt_ignoreSSL;
options.rejectUnauthorized = !opt_ignoreSSL;
}

if (opt_proxy) {
options.proxy = Downloader.resolveProxy_(fileUrl, opt_proxy);
if (options.url.indexOf('https://') === 0) {
options.url = options.url.replace('https://', 'http://');
}
}

request(options)
.on('response',
Expand Down

0 comments on commit fa48354

Please sign in to comment.