Description
This node is a drop-in replacement for HTTPRequest and should not require
modifications to existing codebases.
Data is cached in Godot's user:// folder, specifically user://http_cache/,
with requests further sorted into subdirectories.
Note: HTTPAPI.request() only ever returns Error.OK
because this node manages a queue of requests and handles sending them in the
background.
Warning: See the notes and warnings on HTTPRequest for limitations
and example usage.
Warning: This project follows Semantic Versioning.
Because the Major version is not yet 1, the API (or any aspect of this plugin)
may change at any time.
Settings
While HTTPAPI is rather opinionated, it does expose a small selection of
settings including those related to caching, retrying failed requests, rate
limiting, and debugging.
General
| Setting | Type | Purpose |
|---|---|---|
is_paused |
bool |
Halts the sending of queued HTTP(S) requests when true. Does not stop requests already in-flight. Note that request_completed will still fire when in-flight requests resolve. |
rate_limit_interval |
float |
The interval between queued requests. Cached responses circumvent rate limiting entirely. |
retries_maximum |
int |
The maximum number of times an HTTP request will be retried. Setting retries_maximum to a negative value will cause requests to be retried indefinitely. This is not recommended. |
Caching
| Setting | Type | Purpose |
|---|---|---|
cache_max_age |
int |
The maximum allowable age, in seconds, of cached resources if the max-age header is not present. Defaults to 24 hours. |
cache_override_max_age |
bool |
When true, always override the max-age header with cache_max_age |
Debugging
| Setting | Type | Purpose |
|---|---|---|
do_debug_log |
bool |
Prints debug information to the console. |
Clearing the Cache
Clears a specific cache item if a url is provided, otherwise it the entire
cache is cleared.
A partial url can be provided, but it must be complete up to the final given
path component. This will remove any cached resources nested within that final
path component.
Headers
HTTPAPI appends a few quality-of-life headers to all responses.
| Header | Constant | Purpose |
|---|---|---|
HTTP-API-URL |
STR_HEADER_URL |
The requested URL. |
HTTP-API-Cached |
STR_HEADER_CACHED |
true if the request was cached, false if not. |
HTTP-API-Cache-Age |
STR_HEADER_CACHE_AGE |
The age of the cached response in seconds. |
Example Uncached Response Headers
HTTP-API-URL: https://pokeapi.co/api/v2/pokemon/
HTTP-API-Cached: false
Example Cached Response Headers
HTTP-API-URL: https://pokeapi.co/api/v2/pokemon/
HTTP-API-Cached: true
HTTP-API-Cache-Age: 109
Changelog for version v0.5.0
No changelog provided for this version.