NNG_HTTP_REQ_ADD_HEADER(3http)

πŸ“¦ version 1.11, in alpine 3.24

🌸 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 πŸ‘‘


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