NNG_HTTP_RES_ADD_HEADER(3http)

πŸ“¦ version 1.11, in alpine 3.24

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


xoxo, your Unix bestie 🧚 β€” that's the tea from NNG_HTTP_...ADD_HEADER(3http), dated 2026-01-13 πŸ’œ

πŸ“¦ where this page comes from