CHttpPostTask is a simple IRunnable wrapper that sends an HTTP POST request in a background thread. It is designed for fire-and-forget operations like telemetry, audit logging, and status reporting where the response is not needed.
Header: nel/web/http_post_task.h
#include <nel/web/http_post_task.h>
#include <nel/misc/thread.h>
// Create and launch a background POST
NLMISC::IThread *thread = NLMISC::IThread::create(
new NLWEB::CHttpPostTask(
"https://admin.example.com", // host
"/api/audit", // page
"action=login&user=admin" // POST parameters
)
);
thread->start();
// No need to wait — the thread cleans up after itself
| Method | Description |
|---|---|
CHttpPostTask(host, page, params) |
Constructor. Stores the target host, page path, and POST parameters. |
run() |
Thread entry point. Connects, sends the POST, receives the response (discarded), and disconnects. |
Internally, CHttpPostTask::run() creates a temporary CCurlHttpClient, connects to the host, sends the POST request, receives and discards the response, then disconnects. The entire operation is self-contained within the thread.
The EGS uses CHttpPostTask for audit logging of admin commands:
char params[1024];
sprintf(params, "action=audit&cmd=%s&name=%s", command.c_str(), name.c_str());
NLMISC::IThread *thread = NLMISC::IThread::create(
new NLWEB::CHttpPostTask(host, page, params)
);
thread->start();
This allows the server to log admin actions to an external HTTP endpoint without blocking the game tick.