Skip to content

MTY_HttpAsyncRequest

chrisd1100 edited this page Aug 25, 2022 · 3 revisions

Dispatch an HTTP request to the global HTTP thread pool.

void MTY_HttpAsyncRequest(
    uint32_t *   index,
    const char * host,
    uint16_t     port,
    bool         secure,
    const char * method,
    const char * path,
    const char * headers,
    const void * body,
    size_t       size,
    uint32_t     timeout,
    bool         image
);

Parameters

index (uint32_t *)

The thread index to dispatch the request on. This variable acts as a pseudo context as it should be initialized to 0, then is set to a new index internally. If a request is dispatched using an index already executing, the thread is automatically cleared and the new request is dispatched to a different thread.

host (const char *)

Hostname.

port (uint16_t)

Port. May be set to 0 to use either port 80 or 443 depending on the value of the secure argument.

secure (bool)

If true, make an HTTPS request, otherwise HTTP.

method (const char *)

The HTTP method, i.e. GET or POST.

path (const char *)

Path to the resource.

headers (const char *)

HTTP header key/value pairs in the format Key:Value separated by newline characters.

May be NULL for no additional headers.

body (const void *)

Request payload.

size (size_t)

timeout (uint32_t)

Time the thread will wait in milliseconds for completion.

image (bool)

Attempt to decompress an image response. If successful, the size argument supplied to MTY_HttpAsyncPoll will be set to width | height << 16.

Platform support

Windows   macOS   Android   Linux   Web  

See also

Module: Net

Clone this wiki locally