NNG_HTTP_RES_SET_REASON(3http)
π 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 π
nng_http_res_alloc(3http)nng_http_req_get_reason(3http)nng_http_req_set_status(3http)nng(7)
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
- 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