Skip to content

C API: HTTP

The core's network traffic (the gate source and the native check) goes through a sona_http, which holds user and send(user, request, reply). send starts the request and returns; the layer finishes it later, from any thread, with sona_http_done. A sona_http_request holds method ("GET" or "POST"), url, headers (NULL-terminated "Name: value" strings, may be NULL), body, body_len and timeout_ms.

A layer the host supplies sees every URL, header and answer in clear, the gate's session key included.

sona_http_done

void sona_http_done(sona_http_reply *reply, int status, const void *body,
                    size_t len);
Parameter and type Meaning
reply
sona_http_reply *
The reply the layer was handed (required)
status
int
The HTTP status; 0 or less when the request failed
body
const void *
The reply's body (required)
len
size_t
How many bytes there are

Returns Nothing.

Finishes one HTTP request. status is the HTTP status, or 0 when the request could not be made. The body is copied. Call it exactly once per reply; the reply stays valid until then, even after sona_close. May be called from any thread.

sona_http_platform

const sona_http *sona_http_platform(void);

Returns const sona_http *.

Example:

const sona_http * x_got = sona_http_platform();
printf("sona_http_platform: %s\n", x_got ? "a value" : "none");

The platform's own layer: WinHTTP on Windows, libcurl loaded at run time on Linux, NSURLSession on Apple platforms. NULL where there is none (Xbox 360, WASM, Linux without libcurl): the host must then pass its own in sona_config.http.

This page as Markdown · All the docs as one file (llms-full.txt)