fetch_http library

Fetch API binding to HTTP and HTTPS resources.

Usage: import package:datatools/fetch_http.dart

Classes

Anchor
An interface for a resource anchor.
Body
An interface for accessing content body as String, bytes or JSON objects.
Content
Content represents a data entity.
Controlled<C>
An interface to set control data to a client (ie. HTTP client or fetcher).
FetchApi<C extends Content>
An interface to fetch data from a resource like Web API, a cache or a file.
Fetcher<C extends Content>
A interface supporting FetchApi for fetching and Controlled for control data.
Head represents meta data for some content.
HttpAdapter
An adapter that HttpFetcher instances uses to call http.Client.
HttpContent
HTTP content providing body and stream access for a HTTP response data.
HttpFetcher
A Fetcher implementation for accessing HTTP or HTTPS resources.

Enums

OriginFailure
Common failure types related to OriginException.

Mixins

FetchMixin<C extends Content>
A mixin for FetchApi with partial implemention.

Functions

fetch(Uri url, {Map<String, String>? headers}) Future<Content>
Fetch (read fully) content body from a HTTP(S) resource identified by url.
fetchBytes(Uri url, {Map<String, String>? headers}) Future<Uint8List>
Fetch content body as bytes from a HTTP(S) resource identified by url.
fetchJson(Uri url, {Map<String, String>? headers, Object? reviver(Object? key, Object? value)?}) Future
Fetch content body as JSON data from a HTTP(S) resource identified by url.
fetchStream(Uri url, {Map<String, String>? headers}) Future<Content>
Fetch content as a stream from a HTTP(S) resource identified by url.
fetchText(Uri url, {Map<String, String>? headers}) Future<String>
Fetch content body as text from a HTTP(S) resource identified by url.

Typedefs

HttpValidator = HttpContent Function(Uri reference, BaseResponse response)
A function to validate a HTTP response, and return HttpContent if success.
UriResolver = Uri Function(Uri reference)
A function to resolve an absolute URI from an URI reference.

Exceptions / Errors

ApiException
An exception occurred when accessing an API.
ClientException
An exception occurred when accessing an API and caused by client-side code.
HttpException
An exception originating from a HTTP response with non-success status code.
OriginException
An exception containing a failure message as a response from an API origin.