/* * httpclient.h — thin async HTTP client. * * Two impls share this header: * httpclient_native.cpp — libcurl-multi, polled from http_pump(). * httpclient_web.cpp — emscripten_fetch; http_pump() is a no-op. * * Callbacks fire on the main thread: native impls dispatch from http_pump(), * web from the Emscripten runtime (which is already main-thread). * * The `body` pointer in http_response_t is only valid for the duration of * the callback — copy what you need. */ #ifndef KOBO_HTTPCLIENT_H #define KOBO_HTTPCLIENT_H #include typedef struct http_response_t { int status; // HTTP status code; 0 = network/transport failure const char *body; // NUL-terminated; valid only during the callback size_t len; } http_response_t; typedef void (*http_callback_t)(const http_response_t *resp, void *user); #ifdef __cplusplus extern "C" { #endif void http_init(void); void http_shutdown(void); void http_post_json(const char *url, const char *body, http_callback_t cb, void *user); void http_get(const char *url, http_callback_t cb, void *user); void http_pump(void); #ifdef __cplusplus } #endif #endif /* KOBO_HTTPCLIENT_H */