Skip to content

C3Http

Inherits: RefCounted

General-purpose async HTTP client that requires no scene tree.

Description

Call the static request() from anywhere — no Node to add or configure. Every call awaits a C3Http.Response carrying ok as a single failure check that covers transport errors, timeouts, and non-2xx statuses alike.

Methods

Returns Signature
C3Http.Response request(url: String, custom_headers: PackedStringArray = PackedStringArray(), method: HTTPClient.Method = 0, request_data: String = "", options: C3Http.Options = null)
C3Http.Response request_raw(url: String, custom_headers: PackedStringArray = PackedStringArray(), method: HTTPClient.Method = 2, request_data_raw: PackedByteArray = PackedByteArray(), options: C3Http.Options = null)

Constants

VERSION = "v0.4.0"

The installed version of this addon, e.g. for logging or feature gating.

Method Descriptions

request

func request(
    url: String,
    custom_headers: PackedStringArray = PackedStringArray(),
    method: HTTPClient.Method = 0,
    request_data: String = "",
    options: C3Http.Options = null
) -> C3Http.Response:

Sends an HTTP request to url and returns the response.

custom_headers are sent alongside any headers injected by accept_gzip.

method is an HTTPClient.Method value; defaults to METHOD_GET.

request_data is the raw request body string.

options controls timeout, redirects, and other per-request settings; null uses all defaults.

request_raw

func request_raw(
    url: String,
    custom_headers: PackedStringArray = PackedStringArray(),
    method: HTTPClient.Method = 2,
    request_data_raw: PackedByteArray = PackedByteArray(),
    options: C3Http.Options = null
) -> C3Http.Response:

Sends an HTTP request with a raw byte-array body, like request() but the body is sent as-is without UTF-8 encoding. Use for binary payloads (encoded files, serialized data, custom binary protocols).

request_data_raw is the raw request body bytes.

method defaults to METHOD_POST; a raw body is ignored on METHOD_GET.

See request() for the remaining parameters.