NNG_HTTP_RES_SET_STATUS(3http)
π NAME π
hii bestie, welcome to the NNG Reference Manual page for nng_http_res_set_status β aka NNG_HTTP_...SET_STATUS(3http). The whole vibe: set HTTP response status. Thatβs it, thatβs the job. β¨
πΈ SYNOPSIS πΈ
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_res_set_status(nng_http_res *res, uint16_t status);
π¦ DESCRIPTION π¦
okay so nng_http_res_set_status() sets the numeric HTTP status code associated with the response res to status. The default value for a newly allocated response is 200 (NNG_HTTP_STATUS_OK) β iconic, honestly. π
β οΈ but bestie, listen: the status is not verified, so the caller should take care to ensure that only a valid code is supplied. no cap, it will not hold your hand on this one. π
For convenience, a number of predefined symbols are available:
enum {
NNG_HTTP_STATUS_CONTINUE = 100,
NNG_HTTP_STATUS_SWITCHING = 101,
NNG_HTTP_STATUS_PROCESSING = 102,
NNG_HTTP_STATUS_OK = 200,
NNG_HTTP_STATUS_CREATED = 201,
NNG_HTTP_STATUS_ACCEPTED = 202,
NNG_HTTP_STATUS_NOT_AUTHORITATIVE = 203,
NNG_HTTP_STATUS_NO_CONTENT = 204,
NNG_HTTP_STATUS_RESET_CONTENT = 205,
NNG_HTTP_STATUS_PARTIAL_CONTENT = 206,
NNG_HTTP_STATUS_MULTI_STATUS = 207,
NNG_HTTP_STATUS_ALREADY_REPORTED = 208,
NNG_HTTP_STATUS_IM_USED = 226,
NNG_HTTP_STATUS_MULTIPLE_CHOICES = 300,
NNG_HTTP_STATUS_STATUS_MOVED_PERMANENTLY = 301,
NNG_HTTP_STATUS_FOUND = 302,
NNG_HTTP_STATUS_SEE_OTHER = 303,
NNG_HTTP_STATUS_NOT_MODIFIED = 304,
NNG_HTTP_STATUS_USE_PROXY = 305,
NNG_HTTP_STATUS_TEMPORARY_REDIRECT = 307,
NNG_HTTP_STATUS_PERMANENT_REDIRECT = 308,
NNG_HTTP_STATUS_BAD_REQUEST = 400,
NNG_HTTP_STATUS_UNAUTHORIZED = 401,
NNG_HTTP_STATUS_PAYMENT_REQUIRED = 402,
NNG_HTTP_STATUS_FORBIDDEN = 403,
NNG_HTTP_STATUS_NOT_FOUND = 404,
NNG_HTTP_STATUS_METHOD_NOT_ALLOWED = 405,
NNG_HTTP_STATUS_NOT_ACCEPTABLE = 406,
NNG_HTTP_STATUS_PROXY_AUTH_REQUIRED = 407,
NNG_HTTP_STATUS_REQUEST_TIMEOUT = 408,
NNG_HTTP_STATUS_CONFLICT = 409,
NNG_HTTP_STATUS_GONE = 410,
NNG_HTTP_STATUS_LENGTH_REQUIRED = 411,
NNG_HTTP_STATUS_PRECONDITION_FAILED = 412,
NNG_HTTP_STATUS_PAYLOAD_TOO_LARGE = 413,
NNG_HTTP_STATUS_ENTITY_TOO_LONG = 414,
NNG_HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415,
NNG_HTTP_STATUS_RANGE_NOT_SATISFIABLE = 416,
NNG_HTTP_STATUS_EXPECTATION_FAILED = 417,
NNG_HTTP_STATUS_TEAPOT = 418,
NNG_HTTP_STATUS_UNPROCESSABLE_ENTITY = 422,
NNG_HTTP_STATUS_LOCKED = 423,
NNG_HTTP_STATUS_FAILED_DEPENDENCY = 424,
NNG_HTTP_STATUS_UPGRADE_REQUIRED = 426,
NNG_HTTP_STATUS_PRECONDITION_REQUIRED = 428,
NNG_HTTP_STATUS_TOO_MANY_REQUESTS = 429,
NNG_HTTP_STATUS_HEADERS_TOO_LARGE = 431,
NNG_HTTP_STATUS_UNAVAIL_LEGAL_REASONS = 451,
NNG_HTTP_STATUS_INTERNAL_SERVER_ERROR = 500,
NNG_HTTP_STATUS_NOT_IMPLEMENTED = 501,
NNG_HTTP_STATUS_BAD_GATEWAY = 502,
NNG_HTTP_STATUS_SERVICE_UNAVAILABLE = 503,
NNG_HTTP_STATUS_GATEWAY_TIMEOUT = 504,
NNG_HTTP_STATUS_HTTP_VERSION_NOT_SUPP = 505,
NNG_HTTP_STATUS_VARIANT_ALSO_NEGOTIATES = 506,
NNG_HTTP_STATUS_INSUFFICIENT_STORAGE = 507,
NNG_HTTP_STATUS_LOOP_DETECTED = 508,
NNG_HTTP_STATUS_NOT_EXTENDED = 510,
NNG_HTTP_STATUS_NETWORK_AUTH_REQUIRED = 511,
};
Please see the relevant HTTP RFCs for the semantics and correct use of these status codes. iykyk, the RFCs are the lore. πβ¨
β¨ Tip β¨ It is a good idea to also set the reason message with nng_http_set_reason(). This will help any humans who may have to diagnose a failure. future-you and random debuggers will thank you, fr fr. π«Ά
π RETURN VALUES π
This function returns 0 on success, and non-zero otherwise. slay when itβs 0, sigh when itβs not. π
π ERRORS π
NNG_ENOTSUPβ No support for HTTP in the library. like, the HTTP girlies are simply not here. π
π SEE ALSO π
nng_http_res_alloc(3http), nng_http_req_get_status(3http), nng_http_req_set_reason(3http), nng(7)
okay thatβs the whole page bestie! this came from the NNG Reference Manual, page NNG_HTTP_...SET_STATUS(3http), dated 2026-01-13. mwah πβ¨
π¦ 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