From 21bbedaf04481fb0775f9eb4854aa248267e607e Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 8 Mar 2014 06:18:44 -0500 Subject: [PATCH] added option to download a file without using the configured proxy Former-commit-id: 234d9ba35d11459473a2f6311ffe4fc56003a083 --- .../dependencycheck/utils/Downloader.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Downloader.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Downloader.java index 7c6136860..ef66d2d1f 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Downloader.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/Downloader.java @@ -46,14 +46,26 @@ public final class Downloader { /** * Retrieves a file from a given URL and saves it to the outputPath. * - * @param url the URL of the file to download. - * @param outputPath the path to the save the file to. - * @throws DownloadFailedException is thrown if there is an error downloading the file. + * @param url the URL of the file to download + * @param outputPath the path to the save the file to + * @throws DownloadFailedException is thrown if there is an error downloading the file */ public static void fetchFile(URL url, File outputPath) throws DownloadFailedException { + fetchFile(url, outputPath, true); + } + + /** + * Retrieves a file from a given URL and saves it to the outputPath. + * + * @param url the URL of the file to download + * @param outputPath the path to the save the file to + * @param useProxy whether to use the configured proxy when downloading files + * @throws DownloadFailedException is thrown if there is an error downloading the file + */ + public static void fetchFile(URL url, File outputPath, boolean useProxy) throws DownloadFailedException { HttpURLConnection conn = null; try { - conn = URLConnectionFactory.createHttpURLConnection(url); + conn = URLConnectionFactory.createHttpURLConnection(url, useProxy); conn.setRequestProperty("Accept-Encoding", "gzip, deflate"); conn.connect(); } catch (IOException ex) {