fetch_client 1.0.2 copy "fetch_client: ^1.0.2" to clipboard
fetch_client: ^1.0.2 copied to clipboard

Platformweb

Client for http package based on Fetch API, enables streamed and cancelable requests on web and more.

Fetch Client #

pub package package publisher

This package provides package:http client based on Fetch API.

It's a drop-in solution for extensions with Manifest V3.

Features #

  • 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 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.

Source: Fetch. Living Standard — Last Updated 19 June 2023

Therefore if your request is larger than 64KiB (this includes some other data, so effectively recommended check is 60KiB) you must explicitly set BaseRequest.persistentConnection to false, otherwise request will fail.

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 and Chrome Developers blog for more info.

18
likes
130
pub points
92%
popularity

Publisher

unverified uploader

Client for http package based on Fetch API, enables streamed and cancelable requests on web and more.

Repository (GitHub)
View/report issues

Topics

#fetch #http

Documentation

API reference

License

ISC (LICENSE)

Dependencies

fetch_api, http

More

Packages that depend on fetch_client