NNG_HTTP_RES_SET_REASON(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… nng_http_res_set_reason β€” like, the reason-phrase setter, bestie

okay so this is from the NNG Reference Manual, and the function we're obsessing over today is nng_http_res_set_reason(3http). yes she's got the 3http section suffix and yes she's iconic for it πŸŽ€


✨ NAME ✨

nng_http_res_set_reason β€” set the HTTP response reason πŸ’¬


🌸 SYNOPSIS 🌸

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

int nng_http_res_set_reason(nng_http_res *res, const char *reason);

like, two includes, one function, no cap 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so nng_http_res_set_reason() sets the human readable reason that's tied to the response res, and it sets it to reason. that's the whole vibe honestly ✨

and here's the cute part: if reason is NULL β€” which is literally the default β€” then a default reason phrase gets supplied for you, based on whatever the status code is (peep nng_http_res_set_status() for that one πŸ‘€).

πŸ’‘ Tip: the reason is never parsed automatically, bestie. it's purely a hint for humans, to help them understand the nature of any erroneous result. it's giving "emotional support string" 😭

also important: a local copy of reason is made inside the response res. so like, your string gets duplicated, she's not holding a pointer to your business 🧚


πŸ’– RETURN VALUES πŸ’–

returns 0 on success, and non-zero otherwise. that's it, that's the whole check 🌈


πŸ’€ ERRORS πŸ’€

  • NNG_ENOMEM β€” insufficient memory to perform the operation. the allocator said no πŸ™ˆ
  • NNG_ENOTSUP β€” no support for HTTP in the library. like, HTTP isn't even a thing in this build, so, yeah πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page!! mwah πŸ’‹ this one's from the NNG Reference Manual, dated 2026-01-13 β€” go forth and set those reasons, bestie, periodt πŸŽ€πŸ’œ

πŸ“¦ where this page comes from