Mercurial
diff seobeo/s_web.c @ 244:b8aa08503378
[tools] Add sandboxed online LaTeX editor
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 03 Aug 2026 16:56:25 -0700 |
| parents | 543df0fe7168 |
| children | 117c4d53c9a4 |
line wrap: on
line diff
--- a/seobeo/s_web.c Mon Aug 03 15:26:44 2026 -0700 +++ b/seobeo/s_web.c Mon Aug 03 16:56:25 2026 -0700 @@ -4,6 +4,20 @@ static char g_folder_path[512] = "."; +static char *canonical_request_header(char *header) +{ + if (strcasecmp(header, "content-length") == 0) return "Content-Length"; + if (strcasecmp(header, "content-type") == 0) return "Content-Type"; + if (strcasecmp(header, "connection") == 0) return "Connection"; + if (strcasecmp(header, "authorization") == 0) return "Authorization"; + if (strcasecmp(header, "host") == 0) return "Host"; + if (strcasecmp(header, "upgrade") == 0) return "Upgrade"; + if (strcasecmp(header, "x-real-ip") == 0) return "X-Real-IP"; + if (strcasecmp(header, "sec-websocket-key") == 0) return "Sec-WebSocket-Key"; + if (strcasecmp(header, "sec-websocket-version") == 0) return "Sec-WebSocket-Version"; + return header; +} + char* Seobeo_Web_LoadFile(const char *file_path, size_t *p_file_size) { char full_path[1024]; @@ -58,7 +72,11 @@ case HTTP_UNAUTHORIZED: status_text = "Unauthorized"; break; case HTTP_FORBIDDEN: status_text = "Forbidden"; break; case HTTP_NOT_FOUND: status_text = "Not Found"; break; + case HTTP_PAYLOAD_TOO_LARGE: status_text = "Content Too Large"; break; + case HTTP_UNPROCESSABLE_CONTENT: status_text = "Unprocessable Content"; break; + case HTTP_TOO_MANY_REQUESTS: status_text = "Too Many Requests"; break; case HTTP_INTERNAL_ERROR: status_text = "Internal Server Error"; break; + case HTTP_SERVICE_UNAVAILABLE: status_text = "Service Unavailable"; break; case 502: status_text = "Bad Gateway"; break; case 504: status_text = "Gateway Timeout"; break; default: status_text = "Unknown"; break; @@ -494,7 +512,11 @@ memcpy(val, val_start, value_len); val[value_len] = '\0'; - Dowa_HashMap_Push_Arena(*pp_map, key, val, p_arena); + Dowa_HashMap_Push_Arena( + *pp_map, + canonical_request_header(key), + val, + p_arena); } line = next + 2;