This package provides package:http client based on Fetch API.
It's a drop-in solution for extensions with Manifest V3.
- Cancel requests.
- Support data streaming:
- Get response as
Stream. - Optionally send
Streamas request body (supported only in Chromium 105+ based browsers).
- Get response as
- Get access to redirect URL and status.
- Support non-
200responses (fetchwill only fail on network errors). - Simulate redirects responses via probe request and artificial
locationheader.
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.
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 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.