Skip to main content

Easy Request Maker (erm)

Makes it easy to download files off the internet and communicate with HTTP servers.

Functions

Dictionary awaited_request(String url, bool parse_utf8, HTTPClient.Method method = HTTPClient.Method.METHOD_GET, PackedStringArray headers = PackedStringArray([]), String data = "")

Awaiting required

Using the await keyword is required for this function.

Requests a file from the internet.

The returned Dictionary has the following structure (example):

{ "result": 0, "http_code": 200, "headers": [ "Server": "nginx" ], "body": [], "body_utf8": [] }
^ ^ ^ ^ ^
| | | | |
| | | | --------- The body from the server, as a UTF-8 string (set to "" if 'parse_utf8' is false)
| | | ----------------------- The body from the server, as bytes
| | ------------------------------------------------------ A array of headers
| ---------------------------------------------------------------------- The HTTP response code
------------------------------------------------------------------------------------ Equal to @GlobalScope.Error. If not 0/Error.OK = the request failed

Variant oneline_awaited_request(String url, bool return_utf8 = true, bool ignore_http_code = false HTTPClient.Method method = HTTPClient.Method.METHOD_GET, PackedStringArray headers = PackedStringArray([]), String data = "")

Awaiting required

Using the await keyword is required for this function.

Requests a file from the internet without returning the godot code, http code or headers. Useful for oneliners.

Returns null on error. To ignore HTTP errors (ie. non-200 statuses) set ignore_http_code to true. Returns a UTF-8 string with return_utf8 turned on, returns bytes when turned off.

Array[Dictionary] batch_awaited_request(PackedStringArray urls, bool parse_utf8, HTTPClient.Method method = HTTPClient.Method.METHOD_GET, PackedStringArray headers = PackedStringArray([]), String data = "")

Awaiting required

Using the await keyword is required for this function.

Requests multiple file from the internet.

The returned Dictionarys have the following structure (example):

{ "result": 0, "http_code": 200, "headers": [ "Server": "nginx" ], "body": [], "body_utf8": [] }
^ ^ ^ ^ ^
| | | | |
| | | | --------- The body from the server, as a UTF-8 string (set to "" if 'parse_utf8' is false)
| | | ----------------------- The body from the server, as bytes
| | ------------------------------------------------------ A array of headers
| ---------------------------------------------------------------------- The HTTP response code
------------------------------------------------------------------------------------ Equal to @GlobalScope.Error. If not 0/Error.OK = the request failed

int create_request(String , HTTPClient.Method method = HTTPClient.Method.METHOD_GET, PackedStringArray headers = PackedStringArray([]), String body = "")

warning

You'll probably not need this. Only use this function when implementing your own downloading method.

Creates a new request and stores it in the queue. Returns the download id.

void start_request(int id, bool parse_utf8)

Awaiting required

Using the await keyword is required for this function.

warning

You'll probably not need this. Only use this function when implementing your own downloading method.

Configures and starts a queued request.

bool is_url_allowed(String )

Checks if url can be used.

bool is_request_completed(int id)

Returns if a request has completed yet.

void clean_queue()

Cleans the request queue.

void clean_completed()

Cleans the completed requests list.