NNG_HTTP_RES_SET_HEADER(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸŽ€ nng_http_res_set_header

okay so bestie, this is a page straight out of the NNG Reference Manual β€” the 3http section, to be exact β€” and it's all about one very specific little glow-up move for your HTTP responses. slay. let's get into it πŸ’…


✨ NAME ✨

nng_http_res_set_header β€” set HTTP response header. that's it, that's the whole vibe. one job, done iconically πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nng/nng.h>
#include <nng/supplemental/http/http.h>

int nng_http_res_set_header(nng_http_res *res, const char *key,
    const char *val);

look at her. three arguments, returns an int, no drama 🌸


πŸ’œ DESCRIPTION πŸ’œ

so nng_http_res_set_header() sets the HTTP header for the response res, and it sets the key to the val. simple as that, no cap.

both key and val are copied β€” like, the function keeps its own little copy, so you don't have to stress about what happens to your strings afterwards. and here's the main character move: any previous header with the same key gets replaced. out with the old, in with the new 🫢

πŸ’‘ Tip β€” if you don't want to replace, and you'd rather stack up extra headers with the same key, go see nng_http_res_add_header(). she's the "and also add this" girlie.

okay now the important detail nobody reads until it bites them 😭 the value of key is case insensitive, and it should not include the final colon in an HTTP header. so for example, specifying Host or hOSt are equivalent β€” same thing, literally β€” whereas the value Host: is not a legal header key. that colon? leave it in the drafts bestie, don't invite it πŸ™ˆ


πŸ”₯ RETURN VALUES πŸ”₯

this function returns 0 on success, and non-zero otherwise. classic. iconic. predictable queen πŸ‘‘


πŸ’€ ERRORS πŸ’€

  • NNG_ENOMEM β€” insufficient memory to perform the operation. the machine said "not today" 😭 not enough memory for what you're trying to do.
  • NNG_ENOTSUP β€” no support for HTTP in the library. like, the HTTP machinery just isn't there in this build. can't do it 🫠

🌈 SEE ALSO 🌈

the whole friend group, go say hi:


<div>okay that's the whole page, mwah πŸ’‹ this one's from the NNG reference manual, dated 2026-01-13, and the header bar up top spells her name roughly NNG_HTTP_...SET_HEADER(3http) β€” yes it's abbreviated, no we don't know why, we still love her. go set some headers, bestie, you're gonna ate it up β­πŸ§šβ€β™€οΈπŸ“</div>

πŸ“¦ where this page comes from