NNG_HTTP_...LOC_ERROR(3http)
π NAME π
nng_http_res_alloc_error β allocate HTTP error response. This is the NNG_HTTP_...LOC_ERROR(3http) page from the NNG Reference Manual, bestie, and it's literally about making error responses the easy way β¨
πΈ SYNOPSIS πΈ
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_res_alloc_error(nng_http_res **resp, uint16_t status);
π¦ DESCRIPTION π¦
Okay so nng_http_res_alloc_error() allocates a brand-new HTTP response structure and stores a pointer to it in resp. Iconic. π
That response comes initialized with:
- the status code
status - a corresponding reason phrase
- a simple HTML page containing the same information, generated and attached to the response
Relevant HTTP headers are set too, like Content-Type and Content-Length. The HTTP protocol version is also set to "HTTP/1.1" β periodt. π₯
Tip: This is the simplest way to generate an error response. No cap, it's giving shortcut energy. π«Ά
π RETURN VALUES π
This function returns 0 on success, and non-zero otherwise. That's it, bestie. β¨
π ERRORS π
NNG_ENOMEMβ insufficient free memory exists to allocate a message. πNNG_ENOTSUPβ HTTP support not configured. π
π SEE ALSO π
nng_http_res_alloc(3http)nng_http_res_free(3http)nng_http_res_set_reason(3http)nng_http_res_set_status(3http)nng_strerror(3)nng(7)
okay that's the whole page, bestie β from the NNG Reference Manual, dated 2026-01-13, page NNG_HTTP_...LOC_ERROR(3http). stay slay π
β¨
π¦ 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