Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly pass 'proxy' and 'strictSSL' values through download functions #931

Merged
merged 3 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function getNoopStatus(): Status {
};
}

function downloadPackage(pkg: Package, logger: Logger, status?: Status, proxy?: string, strictSSL?: boolean): Promise<void> {
function downloadPackage(pkg: Package, logger: Logger, status: Status, proxy: string, strictSSL: boolean): Promise<void> {
status = status || getNoopStatus();

logger.append(`Downloading package '${pkg.description}' `);
Expand All @@ -147,12 +147,12 @@ function downloadPackage(pkg: Package, logger: Logger, status?: Status, proxy?:
}).then(tmpResult => {
pkg.tmpFile = tmpResult;

return downloadFile(pkg.url, pkg, logger, status)
return downloadFile(pkg.url, pkg, logger, status, proxy, strictSSL)
.then(() => logger.appendLine(' Done!'));
});
}

function downloadFile(urlString: string, pkg: Package, logger: Logger, status: Status, proxy?: string, strictSSL?: boolean): Promise<void> {
function downloadFile(urlString: string, pkg: Package, logger: Logger, status: Status, proxy: string, strictSSL: boolean): Promise<void> {
const url = parseUrl(urlString);

const options: https.RequestOptions = {
Expand All @@ -169,7 +169,7 @@ function downloadFile(urlString: string, pkg: Package, logger: Logger, status: S
let request = https.request(options, response => {
if (response.statusCode === 301 || response.statusCode === 302) {
// Redirect - download from new location
return resolve(downloadFile(response.headers.location, pkg, logger, status));
return resolve(downloadFile(response.headers.location, pkg, logger, status, proxy, strictSSL));
}

if (response.statusCode != 200) {
Expand Down
6 changes: 4 additions & 2 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getSystemProxyURL(requestURL: Url): string {
return null;
}

export function getProxyAgent(requestURL: Url, proxy?: string, strictSSL?: boolean): any {
export function getProxyAgent(requestURL: Url, proxy: string, strictSSL: boolean): any {
const proxyURL = proxy || getSystemProxyURL(requestURL);

if (!proxyURL) {
Expand All @@ -32,7 +32,9 @@ export function getProxyAgent(requestURL: Url, proxy?: string, strictSSL?: boole
return null;
}

strictSSL = strictSSL || true;
if (strictSSL === undefined) {
strictSSL = true;
}

const opts = {
host: proxyEndpoint.hostname,
Expand Down