Class HttpDownloader
java.lang.Object
com.dua3.gradle.jdkprovider.provision.HttpDownloader
Simple HTTP downloader with timeouts and basic retry for transient failures.
-
Constructor Summary
ConstructorsConstructorDescriptionHttpDownloader(int connectTimeoutMs, int readTimeoutMs, int retries) Constructs an instance of the HttpDownloader class with specified configuration parameters. -
Method Summary
Modifier and TypeMethodDescriptiondownloadTo(URI uri, Path targetFile) Downloads the content from the specified URI to the target file path.
-
Constructor Details
-
HttpDownloader
public HttpDownloader(int connectTimeoutMs, int readTimeoutMs, int retries) Constructs an instance of the HttpDownloader class with specified configuration parameters.- Parameters:
connectTimeoutMs- the timeout in milliseconds for establishing the HTTP connectionreadTimeoutMs- the timeout in milliseconds for waiting to read data from the HTTP connectionretries- the maximum number of retries to perform for transient failures; must be zero or greater
-
-
Method Details
-
downloadTo
Downloads the content from the specified URI to the target file path. If the target file's parent directory does not exist, it will be created. The method retries the download up to the configured number of retries in case of transient failures.- Parameters:
uri- the URI from which the content will be downloadedtargetFile- the path to the file where the downloaded content will be saved- Returns:
- the path to the target file containing the downloaded content
- Throws:
IOException- if an I/O error occurs during the download, including HTTP errorsInterruptedException- if the operation is interrupted
-