fetch_client 1.1.2 copy "fetch_client: ^1.1.2" to clipboard
fetch_client: ^1.1.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 with WASM support.

It's a drop-in solution for extensions with 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 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, such as headers) BaseRequest.persistentConnection 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 and Chrome Developers blog for more info.

36
likes
150
points
80.2k
downloads

Publisher

verified publishernull.moe

Weekly Downloads

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

Repository (GitHub)
View/report issues

Topics

#web #fetch #http

Documentation

API reference

License

ISC (license)

Dependencies

fetch_api, http

More

Packages that depend on fetch_client