NNG_HTTP_...LOC_ERROR(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸŽ€ 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 πŸ”—


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