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.

@FunctionalInterface public interface IURLDownloader
Callback interface to download data from web. Used e.g. for CRL downloads.
Since:
11.2.0
Author:
Philip Helger
  • Field Details

    • DEFAULT_CONNECT_TIMEOUT_MS

      static final int DEFAULT_CONNECT_TIMEOUT_MS
      The default connection timeout used by createDefault() in milliseconds (10 seconds).
      Since:
      12.2.4
      See Also:
    • DEFAULT_READ_TIMEOUT_MS

      static final int DEFAULT_READ_TIMEOUT_MS
      The default read timeout used by createDefault() in milliseconds (60 seconds).
      Since:
      12.2.4
      See Also:
  • Method Details

    • downloadURL

      byte @Nullable [] downloadURL(@Nonempty @NonNull @Nonempty String sURL) throws Exception
      Download the content of the provided URL
      Parameters:
      sURL - The CRL URL to download. Neither null nor empty.
      Returns:
      null if no payload was returned
      Throws:
      Exception - In case of error
    • createDefault

      static @NonNull IURLDownloader createDefault()
      Returns:
      The default URL downloader using URL.openConnection() with the default connection timeout of DEFAULT_CONNECT_TIMEOUT_MS milliseconds and the default read timeout of DEFAULT_READ_TIMEOUT_MS milliseconds. Never null.
    • createDefault

      static @NonNull IURLDownloader createDefault(int nConnectTimeoutMS, int nReadTimeoutMS)
      Create a default URL downloader using URL.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