Skip to content

http_post_task

Jan Boon edited this page Mar 15, 2026 · 1 revision

title: HTTP POST Task description: Fire-and-forget asynchronous HTTP POST via a background thread published: true date: 2026-03-16T00:00:00.000Z tags: editor: markdown dateCreated: 2026-03-16T00:00:00.000Z

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

Usage

#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

API Reference

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.

How It Works

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.

Ryzom Server Usage

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.

Clone this wiki locally