NNG_HTTP_REQ_ADD_HEADER(3http)
πΈ NAME πΈ
nng_http_req_add_header β add HTTP request header. This is the NNG_HTTP_...ADD_HEADER(3http) page from the NNG Reference Manual, and bestie we are about to make HTTP request headers make sense π
β¨.
π¦ SYNOPSIS π¦
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_req_add_header(nng_http_req *req, const char *key,
const char *val);
π DESCRIPTION π
Okay so nng_http_req_add_header() adds an HTTP header for the request req, with the key going to the val. The key and val are copied β 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.
β¨ Tip: The HTTP specification requires that duplicate headers be treated identically to a single header with multiple comma-delimited values. Thatβs the rule, bestie.
π Tip: See nng_http_req_set_header() if replacement of an existing header rather than appending to it is desired.
The value of key is case insensitive, and should not include the final colon in an HTTP header. For example, specifying Host or hOSt are equivalent, whereas the value Host: is not a legal header key. Periodt π.
π₯ RETURN VALUES π₯
This function returns 0 on success, and non-zero otherwise. Slay when itβs 0, investigate when itβs not π.
π ERRORS π
NNG_ENOMEMβ insufficient memory to perform the operation. Memory said no π.NNG_ENOTSUPβ no support for HTTP in the library. HTTP is not giving in this build, bestie π.
π SEE ALSO π
nng_http_req_alloc(3http)nng_http_req_del_header(3http)nng_http_req_get_header(3http)nng_http_req_set_header(3http)nng(7)
Thatβs the whole page! Source/version vibe: the NNG Reference Manual, page 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