mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-13 23:33:37 +01:00
added option to download a file without using the configured proxy
Former-commit-id: 234d9ba35d11459473a2f6311ffe4fc56003a083
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.
|
||||
*
|
||||
* @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) {
|
||||
|
||||
Reference in New Issue
Block a user