UrlFetcher

fun UrlFetcher(transport: HttpTransport, policy: OutboundUrlPolicy, configure: UrlFetcherConfig.() -> Unit = {}): UrlFetcher(source)

Builds a UrlFetcher over a transport the caller owns. Stable Core. The fetcher never closes the transport. policy is the pre-check's; the transport enforces its own, so pass the same policy to both.

Return

the fetcher.

Parameters

transport

the transport; the caller closes it.

policy

the outbound-URL policy the pre-check applies.

configure

sets the budget, reader, clocks and defaultMaxWait; the defaults when omitted.

Throws

if defaultMaxWait is negative.

fun UrlFetcher(userAgent: String, configure: UrlFetcherConfig.() -> Unit = {}): UrlFetcher(source)

Builds a UrlFetcher for URLs an administrator supplies: an Untrusted policy (OutboundUrlPolicy.untrusted()), an owned OkHttpTransport(userAgent, policy), CallBudget.Unlimited unless budget is set. Stable Core. close() closes the transport. See the overload with a policy to add the deployment's own denied ranges or ports.

Return

the fetcher; the caller closes it.

Parameters

userAgent

the User-Agent sent on every request: non-blank, visible ASCII, no leading or trailing space.

configure

sets the budget, reader, clocks and defaultMaxWait; the defaults when omitted.

Throws

if defaultMaxWait is negative or userAgent is refused by the transport; nothing stays open.


fun UrlFetcher(userAgent: String, policy: OutboundUrlPolicy, configure: UrlFetcherConfig.() -> Unit = {}): UrlFetcher(source)

As the overload without a policy, for a policy of the caller's own: OutboundUrlPolicy.untrusted { extraDeniedRanges += … } adds the deployment's own NAT64 prefix or internal ranges. Stable Core. The transport is built with the policy's settings as they are (an Untrusted policy's concurrency caps are part of what makes it untrusted) and the pre-check applies the same policy.

Return

the fetcher; the caller closes it.

Parameters

userAgent

the User-Agent sent on every request.

policy

the policy the transport enforces and the pre-check applies.

configure

sets the budget, reader, clocks and defaultMaxWait.

Throws

as the overload without a policy, and for a policy.settings.maxResponseBytes above Int.MAX_VALUE - 8.