Mercurial
diff seobeo/s_web.c @ 124:dbf14f84d51c
Refactor Seobeo and mrjunejune build files so it works.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Thu, 08 Jan 2026 07:31:32 -0800 |
| parents | 7b1719fa918c |
| children | 7a63e41a21fb |
line wrap: on
line diff
--- a/seobeo/s_web.c Thu Jan 08 06:46:10 2026 -0800 +++ b/seobeo/s_web.c Thu Jan 08 07:31:32 2026 -0800 @@ -65,13 +65,14 @@ void Seobeo_Web_HandleClientRequest(Seobeo_Handle *p_cli_handle, Seobeo_Cache_Entry *p_html_cache) { - Dowa_Arena *p_request_arena = Dowa_Arena_Create(1*1024*1024); // 1MB for request parsing + // TODO: This should be splitted up instead of handling up to 50 MB as it will fail more often... + Dowa_Arena *p_request_arena = Dowa_Arena_Create(50*1024*1024); // 50 MB because of files... if (!p_request_arena) { perror("Dowa_Arena_Create request"); goto clean_up; } - Dowa_Arena *p_response_arena = Dowa_Arena_Create(5*1024*1024); // 5MB for response + Dowa_Arena *p_response_arena = Dowa_Arena_Create(50*1024*1024); // 50 MB for response if (!p_response_arena) { perror("Dowa_Arena_Create response"); goto clean_up; } - void *p_response_header = Dowa_Arena_Allocate(p_response_arena, (size_t)1024*5); // 5Kb + void *p_response_header = Dowa_Arena_Allocate(p_response_arena, 1024*5); // 5Kb if (!p_response_header) { perror("Dowa_Arena_Allocate"); goto clean_up; } Seobeo_Request_Entry *p_req_map = NULL; @@ -135,6 +136,7 @@ const char *path = p_path_kv ? ((Seobeo_Request_Entry*)p_path_kv)->value : "/"; // --- Check for WebSocket upgrade request --- + #ifdef SEOBEO_WEBSOCKET_SERVER if (Seobeo_WebSocket_Server_Handle_Upgrade(p_cli_handle, p_req_map, path)) { Seobeo_Log(SEOBEO_INFO, "WebSocket connection established\n"); @@ -144,6 +146,7 @@ Dowa_Arena_Free(p_response_arena); return; } + #endif // --- Try to match API route first --- Seobeo_Route_Handler handler = Seobeo_Router_Find_Handler(method, path, &p_req_map, p_request_arena); @@ -730,31 +733,5 @@ g_routes = NULL; } -static char *Seobeo_Log_Level_String(Seobeo_Log_Level level) -{ - switch(level) { - case SEOBEO_DEBUG: return "DEBUG"; - case SEOBEO_INFO: return "INFO"; - case SEOBEO_WARNING: return "WARNING"; - case SEOBEO_ERROR: return "ERROR"; - default: return "INFO"; - } -} +// Logging functions moved to s_logging.c -int Seobeo_Log(Seobeo_Log_Level level, const char * restrict format, ...) -{ - #ifndef SEOBEO_ENABLE_DEBUG - if (level == SEOBEO_DEBUG) - return 0; - #endif - - int result; - va_list args; - printf("[%s] ", Seobeo_Log_Level_String(level)); - va_start(args, format); - result = vprintf(format, args); - va_end(args); - - return result; -} -