fetch

suspend fun fetch(request: HttpRequest, configure: FetchSpec.() -> Unit = {}): Result<HttpResponse>(source)

Fetches request.

Return

the response for any status but a throttle; otherwise a failure: HttpFailure.Closed ("fetcher"), TransportFailure.InvalidRequest (a bad spec or a controlled header), TransportFailure.RefusedByPolicy, HttpFailure.BudgetExhausted, HttpFailure.Closed ("budget" or "transport"), any TransportFailure, or UpstreamFailure.RateLimited.

Parameters

request

the request; its headers must not hold a header the transport controls.

configure

sets the cost, lane and maxWait of this fetch; the defaults when omitted.

Throws

kotlinx.coroutines.CancellationException

if the caller is cancelled.

if a component throws one.