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)
constructor(source: String)

Creates a UrlSource with the default timeouts.

constructor(source: String, connectTimeout: Duration, readTimeout: Duration)

Creates a UrlSource with timeouts given as java.time.Duration, for Java callers: the constructor taking Kotlin durations cannot be called from Java.

Properties

Link copied to clipboard
open override val content: String

The textual content read from this source.

Link copied to clipboard
open override val remote: Boolean = true

Whether this source is remote (URL-based).

Link copied to clipboard
open override val source: String