Package com.helger.base.url
Interface IURLDownloader
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback interface to download data from web. Used e.g. for CRL downloads.
- Since:
- 11.2.0
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default connection timeout used bycreateDefault()in milliseconds (10 seconds).static final intThe default read timeout used bycreateDefault()in milliseconds (60 seconds). -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull IURLDownloaderstatic @NonNull IURLDownloadercreateDefault(int nConnectTimeoutMS, int nReadTimeoutMS) Create a default URL downloader usingURL.openConnection()with the provided connection and read timeouts.byte @Nullable []downloadURL(@NonNull @Nonempty String sURL) Download the content of the provided URL
-
Field Details
-
DEFAULT_CONNECT_TIMEOUT_MS
static final int DEFAULT_CONNECT_TIMEOUT_MSThe default connection timeout used bycreateDefault()in milliseconds (10 seconds).- Since:
- 12.2.4
- See Also:
-
DEFAULT_READ_TIMEOUT_MS
static final int DEFAULT_READ_TIMEOUT_MSThe default read timeout used bycreateDefault()in milliseconds (60 seconds).- Since:
- 12.2.4
- See Also:
-
-
Method Details
-
downloadURL
Download the content of the provided URL- Parameters:
sURL- The CRL URL to download. Neithernullnor empty.- Returns:
nullif no payload was returned- Throws:
Exception- In case of error
-
createDefault
- Returns:
- The default URL downloader using
URL.openConnection()with the default connection timeout ofDEFAULT_CONNECT_TIMEOUT_MSmilliseconds and the default read timeout ofDEFAULT_READ_TIMEOUT_MSmilliseconds. Nevernull.
-
createDefault
Create a default URL downloader usingURL.openConnection()with the provided connection and read timeouts. A timeout value of 0 means infinite (the JVM default), so this is strongly discouraged for downloads from the public Internet.- Parameters:
nConnectTimeoutMS- The connection timeout in milliseconds. Must be ≥ 0.nReadTimeoutMS- The read timeout in milliseconds. Must be ≥ 0.- Returns:
- Never
null. - Since:
- 12.2.4
-