mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-22 00:59:34 +01:00
added option to download a file without using the configured proxy
Former-commit-id: 7153a34a12a02a53bf715fe023e820afd42899d2
This commit is contained in:
@@ -46,14 +46,26 @@ public final class Downloader {
|
|||||||
/**
|
/**
|
||||||
* Retrieves a file from a given URL and saves it to the outputPath.
|
* Retrieves a file from a given URL and saves it to the outputPath.
|
||||||
*
|
*
|
||||||
* @param url the URL of the file to download.
|
* @param url the URL of the file to download
|
||||||
* @param outputPath the path to the save the file to.
|
* @param outputPath the path to the save the file to
|
||||||
* @throws DownloadFailedException is thrown if there is an error downloading the file.
|
* @throws DownloadFailedException is thrown if there is an error downloading the file
|
||||||
*/
|
*/
|
||||||
public static void fetchFile(URL url, File outputPath) throws DownloadFailedException {
|
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;
|
HttpURLConnection conn = null;
|
||||||
try {
|
try {
|
||||||
conn = URLConnectionFactory.createHttpURLConnection(url);
|
conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||||
conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
|
conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
|
||||||
conn.connect();
|
conn.connect();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user