Called on Gateway URLs.
Used to perform a fetch; use this to override the underlying network fetch layer. In NodeJS, the default uses the "http" and "https" libraries and in the browser fetch is used. If you wish to use Axios, this is how you would register it.
Called before any network request, allowing updated headers (e.g. Bearer tokens), etc.
Called on the response, allowing client-based throttling logic or post-processing.
Called prior to each retry; return true to retry, false to abort.
Represents a request for a resource using a URI.
By default, the supported schemes are HTTP, HTTPS, data:, and IPFS:.
Additional schemes can be added globally using registerGateway.
Enable and request gzip-encoded responses. The response will automatically be decompressed. (default: true)
Allow Authentication credentials to be sent over insecure channels. (default: false)
The fetch body, if any, to send as the request body. (default: null)
When setting a body, the intrinsic Content-Type is automatically set and will be used if not overridden by setting a custom header.
If body is null, the body is cleared (along with the intrinsic Content-Type) and the .
If body is a string, the intrincis Content-Type is set to text/plain.
If body is a Uint8Array, the intrincis Content-Type is set to application/octet-stream.
If body is any other object, the intrincis Content-Type is set to application/json.
The value that will be sent for the Authorization header.
To set the credentials, use the setCredentials method.
The headers that will be used when requesting the URI. All keys are lower-case.
This object is a copy, so any chnages will NOT be reflected in the FetchRequest.
To set a header entry, use the setHeader method.
The HTTP method to use when requesting the URI. If no method has been explicitly set, then GET is used if the body is null and POST otherwise.
This function is called prior to each request, for example during a redirection or retry in case of server throttling.
This offers an opportunity to populate headers or update content before sending a request.
This function is called after each response, offering an opportunity to provide client-level throttling or updating response data.
Any error thrown in this causes the send() to throw.
To schedule a retry attempt (assuming the maximum retry limit has not been reached), use [[response.throwThrottleError]].
This function is called on each retry attempt.
The timeout (in milliseconds) to wait for a complere response. (default: 5 minutes)
The fetch URI to requrest.
Create a new FetchRequest instance with default values.
Once created, each property may be set before issuing a .send() to make teh request.
Cancels the inflight response, causing a CANCELLED error to be rejected from the send.
Clear all headers, resetting all intrinsic headers.
Create a new copy of this request.
Get the header for key, ignoring case.
Returns true if the request has a body.
Returns a new FetchRequest that represents the redirection to location.
Resolves to the response by sending the request.
Sets an Authorization for username with password.
Set the header for key to value. All values are coerced to a string.
Update the throttle parameters used to determine maximum attempts and exponential-backoff properties.
Creates a function that can "fetch" data URIs.
Note that this is automatically done internally to support data URIs, so it is not necessary to register it.
This is not generally something that is needed, but may be useful in a wrapper to perfom custom data URI functionality.
Creates a function that will fetch IPFS (unvalidated) from a custom gateway baseUrl.
The default IPFS gateway used internally is "https://gateway.ipfs.io/ipfs/".
Get the current Gateway function for scheme.
Locks all static configuration for gateways and FetchGetUrlFunc registration.
Use the func when fetching URIs using scheme.
This method affects all requests globally.
If lockConfig has been called, no change is made and this throws.
Use getUrl when fetching URIs over HTTP and HTTPS requests.
This method affects all requests globally.
If lockConfig has been called, no change is made and this throws.
The response for a FetchREquest.
The response body, or null if there was no body.
The response body, decoded as JSON.
An error is thrown if the body is invalid JSON-encoded data or if there was no body.
The response body as a UTF-8 encoded string, or the empty string (i.e. "") if there was no body.
An error is thrown if the body is invalid UTF-8 data.
The response headers. All keys are lower-case.
The request made for this response.
The response status code.
The response status message.
Throws a SERVER_ERROR if this response is not ok.
Get the header value for key, ignoring case.
Returns true of the response has a body.
Return a Response with matching headers and body, but with an error status code (i.e. 599) and message with an optional error.
Returns true if this response was a success statusCode.
If called within a request.processFunc call, causes the request to retry as if throttled for stall milliseconds.