NNG_HTTP_RES_ADD_HEADER(3http)
okay so bestie, this is the nng_http_res_add_header(3http) page from the NNG Reference Manual π
π NAME
nng_http_res_add_header β add HTTP response header
β¨ SYNOPSIS
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_res_add_header(nng_http_res *res, const char *key,
const char *val);
π DESCRIPTION
So nng_http_res_add_header() adds an HTTP header to the response res, mapping the header name key to the value val. Both key and val get copied β yes, copied, not borrowed, no cap π«Ά.
If a header with the value of key already exists, then a comma and whitespace separator are appended to it, followed by val β¨.
If no such header already exists, then one is created with the value val. Easy.
π‘ Tip: the HTTP specification requires duplicate headers to be treated identically to a single header with multiple comma-delimited values.
π‘ Tip: peep nng_http_res_set_header() if you want to replace an existing header instead of appending to it π
The value of key is case insensitive, and it should not include the final colon in an HTTP header. For example, Host and hOSt are equivalent, whereas Host: is not a legal header key. periodt π
πΈ RETURN VALUES
This function returns 0 on success, and non-zero otherwise. That's it, that's the vibe check β¨.
π¦ ERRORS
NNG_ENOMEMβ Insufficient memory to perform the operation π.NNG_ENOTSUPβ No support for HTTP in the library.
π₯ SEE ALSO
nng_http_res_alloc(3http)nng_http_res_del_header(3http)nng_http_res_get_header(3http)nng_http_res_set_header(3http)nng(7)
xoxo, your Unix bestie π§ β that's the tea from NNG_HTTP_...ADD_HEADER(3http), dated 2026-01-13 π
π¦ where this page comes from
- alpine 3.24: nng-doc 1.11-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms