decided in favor of dedicated COMPONENT() macro, updates to documentation

This commit is contained in:
udo
2026-04-19 11:34:03 +00:00
parent be514d63d6
commit 2b5586d7df
56 changed files with 926 additions and 401 deletions
+46
View File
@@ -14,6 +14,41 @@
#include "types.h"
namespace {
String http_status_reason(s32 code)
{
switch(code)
{
case 200: return("OK");
case 201: return("Created");
case 202: return("Accepted");
case 204: return("No Content");
case 301: return("Moved Permanently");
case 302: return("Found");
case 303: return("See Other");
case 304: return("Not Modified");
case 307: return("Temporary Redirect");
case 308: return("Permanent Redirect");
case 400: return("Bad Request");
case 401: return("Unauthorized");
case 403: return("Forbidden");
case 404: return("Not Found");
case 405: return("Method Not Allowed");
case 409: return("Conflict");
case 422: return("Unprocessable Content");
case 429: return("Too Many Requests");
case 500: return("Internal Server Error");
case 501: return("Not Implemented");
case 502: return("Bad Gateway");
case 503: return("Service Unavailable");
case 504: return("Gateway Timeout");
default: return("");
}
}
}
SharedUnit::~SharedUnit()
{
if(so_handle)
@@ -45,6 +80,17 @@ void Request::ob_start()
ob = ob_stack.back();
}
void Request::set_status(s32 code, String reason)
{
if(reason == "")
reason = http_status_reason(code);
String prefix = params["GATEWAY_INTERFACE"] != "" ? "Status: " : "HTTP/1.1 ";
response_code = prefix + std::to_string(code);
if(reason != "")
response_code += " " + reason;
flags.status = code;
}
Request::~Request()
{
for(auto* stream : ob_stack)