author: laplante@plcb.ca date: 2024-03-22 title: “HTTP::STATUS Function” version: 1.0.0 section: 1g
http::status — Set the HTTP status code
http::status(code)
The http::status function sets the HTTP response status code.
It supports all standard codes defined in RFCs, including informational,
success, redirection, client error, and server error responses.
Some of the predefined constants include:
StatusContinue = 100StatusSwitchingProtocols = 101StatusProcessing = 102StatusEarlyHints = 103StatusOK = 200StatusCreated = 201StatusAccepted = 202StatusNoContent = 204StatusPartialContent = 206StatusMovedPermanently = 301StatusFound = 302StatusSeeOther = 303StatusTemporaryRedirect = 307StatusPermanentRedirect = 308StatusBadRequest = 400StatusUnauthorized = 401StatusForbidden = 403StatusNotFound = 404StatusConflict = 409StatusTooManyRequests = 429StatusInternalServerError = 500StatusNotImplemented = 501StatusBadGateway = 502StatusServiceUnavailable = 503StatusGatewayTimeout = 504For the complete list, see the official HTTP RFC references (e.g., RFC 9110, RFC 4918, RFC 6585).
// Set response status to 401 Unauthorized
status(http::StatusUnauthorized);
// Set response status to 404 Not Found
status(http::StatusNotFound);
laplante@plcb.ca