android-components / mozilla.components.concept.fetch / Client

Client

abstract class Client (source)

A generic Client for fetching resources via HTTP/s.

Abstract base class / interface for clients implementing the concept-fetch component.

The Request/Response API is inspired by the Web Fetch API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

Constructors

Name Summary
<init> Client()
A generic Client for fetching resources via HTTP/s.

Properties

Name Summary
defaultHeaders val defaultHeaders: Headers
List of default headers that should be added to every request unless overridden by the headers in the request.

Functions

Name Summary
fetch abstract fun fetch(request: Request): Response
Starts the process of fetching a resource from the network as described by the Request object. This call is synchronous.
fetchDataUri fun fetchDataUri(request: Request): Response
Generates a Response based on the provided Request for a data URI.

Companion Object Properties

Name Summary
[DATA_URI_BASE64EXT](/api/mozilla.components.concept.fetch/-client/-d-a-t-a-u-r-i_-b-a-s-e64_-e-x-t.html) const val DATA_URI_BASE64_EXT: String
DATA_URI_CHARSET const val DATA_URI_CHARSET: String
DATA_URI_SCHEME const val DATA_URI_SCHEME: String

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.
withInterceptors fun Client.withInterceptors(vararg interceptors: Interceptor): Client
Creates a new Client instance that will use the provided list of Interceptor instances.

Inheritors

Name Summary
GeckoViewFetchClient class GeckoViewFetchClient : Client
GeckoView (GeckoWebExecutor) based implementation of Client.
HttpURLConnectionClient class HttpURLConnectionClient : Client
HttpURLConnection implementation of Client.
OkHttpClient class OkHttpClient : Client
Client implementation using OkHttp.