chttpclient · Section 3
chttp_default_client
NAME
chttp_default_client - give the default HTTP client of the process
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpclient.h> chttpcli chttp_default_client(void);
DESCRIPTION
This function returns the process's default client, which the library creates the first time it is needed. The function is thread-safe, and a process never gets more than one default client. The default client has the default settings: pool_size is the CPU count, the connect timeout is 30 s, the inactivity timeout is 60 s, there is no request timeout and TLS verification is on. You can change them with the same chttpcli_set_* functions as for any other client.
RETURN VALUE
The handle of the default client, or CHTTPCLI_NULL if the initialization fails.
WARNINGS
Do not pass this handle to chttpcli_destroy. The module owns the default client and destroys it at process exit, from a handler that it registers with atexit(3) when it first builds the client. A call to chttp_default_client from an exit handler that runs after that one returns CHTTPCLI_NULL. If you destroy it anyway, the chttpcli_destroy call does not crash, because the module recognizes the handle and clears its own reference to it. The library never builds the default client again, though, so every later call to chttp_default_client, chttp_do_default, chttp_get and the other wrappers fails cleanly and runs no request, for the rest of the process's life. If you need a client whose lifetime you control, create your own with chttpcli_create or chttpcli_create_mp.
SEE ALSO
chttpcli_create(3), chttpcli_destroy(3), chttp_do_default(3), chttp_get(3)