calog/libs/calogHttp.h

28 lines
1.5 KiB
C

// calogHttp.h -- calog HTTP client library.
//
// Bridges calog scripts to a minimal HTTP/1.1 client so any engine can fetch and post over
// http:// and https:// without an engine-specific library:
// httpGet(url) -> { status, body, headers }
// httpRequest(opts) -> { status, body, headers }
// where opts is a map { method (default "GET"), url, headers (map of name->value), body,
// insecure (bool) }. The result map carries the integer status code, the binary-safe response
// body, and a headers map keyed by the lowercased header name. Each call opens its own
// connection ("Connection: close"), reads the whole response to EOF, and decodes the body
// honoring Transfer-Encoding: chunked / Content-Length / read-to-close. Redirects are NOT
// followed (a 3xx is returned as-is). For https:// the TLS handshake uses SNI and, by DEFAULT,
// verifies the server certificate chain against the system CA store and checks it matches the
// requested hostname (an untrusted or mismatched certificate fails the request). Pass
// insecure=true to httpRequest to skip verification (self-signed / development endpoints).
// The natives are INLINE (each call is a self-contained connection with no shared state), so
// there is nothing to shut down.
#ifndef CALOG_HTTP_H
#define CALOG_HTTP_H
#include "calog.h"
// Register the HTTP natives (httpGet, httpRequest) on a runtime. Stateless: safe to call on
// any number of runtimes, and there is no matching shutdown.
int32_t calogHttpRegister(CalogT *calog);
#endif