Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zekfad/fetch_client
Fetch based Client for HTTP package.
https://github.com/zekfad/fetch_client
dart dart-package dart-web fetch fetch-api
Last synced: 5 days ago
JSON representation
Fetch based Client for HTTP package.
- Host: GitHub
- URL: https://github.com/zekfad/fetch_client
- Owner: Zekfad
- License: isc
- Created: 2023-01-22T20:49:29.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T14:32:31.000Z (3 months ago)
- Last Synced: 2024-08-11T15:46:19.166Z (3 months ago)
- Topics: dart, dart-package, dart-web, fetch, fetch-api
- Language: Dart
- Homepage: https://pub.dev/packages/fetch_client
- Size: 41 KB
- Stars: 23
- Watchers: 3
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Fetch Client
[![pub package](https://img.shields.io/pub/v/fetch_client.svg)](https://pub.dev/packages/fetch_client)
[![package publisher](https://img.shields.io/pub/publisher/fetch_client.svg)](https://pub.dev/packages/fetch_client/publisher)This package provides [package:http](https://pub.dev/packages/http) client based
on [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) with
WASM support.It's a drop-in solution for extensions with
[Manifest V3](https://developer.chrome.com/docs/extensions/mv3/intro/#introducing-manifest-v3).## Features
* WASM-ready internals.
* Cancel requests.
* Support data streaming:
* Get response as `Stream`.
* Optionally send `Stream` as request body (supported only in Chromium 105+
based browsers).
* Get access to redirect URL and status.
* Support non-`200` responses (`fetch` will only fail on network errors).
* Simulate redirects responses via probe request and artificial `location`
header.## Notes
### Large payload
This modules maps `keepalive` to [`BaseRequest.persistentConnection`](https://pub.dev/documentation/http/latest/http/BaseRequest/persistentConnection.html)
which is **`true`** by default.Fetch spec says that maximum request size with `keepalive` flag is 64KiB:
> __4.5. HTTP-network-or-cache fetch__
>
> > 8.10.5: If the sum of _contentLength_ and _inflightKeepaliveBytes_ is greater
> > than 64 kibibytes, then return a [network error](https://fetch.spec.whatwg.org/#concept-network-error).
>
> _Source: [Fetch. Living Standard — Last Updated 19 June 2023](https://fetch.spec.whatwg.org/#http-network-or-cache-fetch)_Therefore if your request is larger than 64KiB (this includes some other data,
such as headers) [`BaseRequest.persistentConnection`](https://pub.dev/documentation/http/latest/http/BaseRequest/persistentConnection.html)
will be ignored and threated as `false`.### Request streaming
Request streaming is supported only in Chromium 105+ based browsers and
requires server to use HTTP/2 or HTTP/3.See [MDN compatibility chart](https://developer.mozilla.org/en-US/docs/Web/API/Request#browser_compatibility)
and [Chrome Developers blog](https://developer.chrome.com/articles/fetch-streaming-requests/#doesnt-work-on-http1x) for more info.