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 = 100
StatusSwitchingProtocols = 101
StatusProcessing = 102
StatusEarlyHints = 103
StatusOK = 200
StatusCreated = 201
StatusAccepted = 202
StatusNoContent = 204
StatusPartialContent = 206
StatusMovedPermanently = 301
StatusFound = 302
StatusSeeOther = 303
StatusTemporaryRedirect = 307
StatusPermanentRedirect = 308
StatusBadRequest = 400
StatusUnauthorized = 401
StatusForbidden = 403
StatusNotFound = 404
StatusConflict = 409
StatusTooManyRequests = 429
StatusInternalServerError = 500
StatusNotImplemented = 501
StatusBadGateway = 502
StatusServiceUnavailable = 503
StatusGatewayTimeout = 504
For 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