UrlSource
open class UrlSource(val source: String, connectTimeout: Duration = DEFAULT_CONNECT_TIMEOUT, readTimeout: Duration = DEFAULT_READ_TIMEOUT) : ContentSource
A ContentSource that reads content from a URL.
content is fetched from source on every access; it is not cached.
The timeouts are applied in whole milliseconds, as java.net.URLConnection requires. A positive timeout is rounded up and capped at Int.MAX_VALUE milliseconds; Duration.INFINITE or Duration.ZERO means no timeout.
Parameters
source
the URL to read content from
connectTimeout
the maximum time to wait for a connection (default 10 seconds)
readTimeout
the maximum time to wait for data once connected (default 30 seconds)
Throws
if either timeout is negative.
Inheritors
Constructors
Link copied to clipboard
constructor(source: String, connectTimeout: Duration = DEFAULT_CONNECT_TIMEOUT, readTimeout: Duration = DEFAULT_READ_TIMEOUT)
Creates a UrlSource with the default timeouts.
Creates a UrlSource with timeouts given as java.time.Duration, for Java callers: the constructor taking Kotlin durations cannot be called from Java.