diff seobeo/s_web.c @ 132:7a63e41a21fb

[Seobeo] Added debug targets.
author June Park <parkjune1995@gmail.com>
date Fri, 09 Jan 2026 08:23:54 -0800
parents dbf14f84d51c
children ffb764d2fcc5
line wrap: on
line diff
--- a/seobeo/s_web.c	Fri Jan 09 07:42:04 2026 -0800
+++ b/seobeo/s_web.c	Fri Jan 09 08:23:54 2026 -0800
@@ -189,15 +189,21 @@
 
     if (p_file_kv)
     {
-      // File is cached
-      file_content = ((Seobeo_Cache_Entry*)p_file_kv)->value;
-      body_size = strlen(file_content);
+      // File is cached - use stored size for binary file support
+      Seobeo_Cached_File *cached = ((Seobeo_Cache_Entry*)p_file_kv)->value;
+      file_content = cached->content;
+      body_size = cached->size;
     }
     else
     {
       file_content = Seobeo_Web_LoadFile(file_path, &body_size);
       if (file_content)
-        Dowa_HashMap_Push(p_html_cache, file_path, file_content);
+      {
+        Seobeo_Cached_File *cached = malloc(sizeof(Seobeo_Cached_File));
+        cached->content = (char*)file_content;
+        cached->size = body_size;
+        Dowa_HashMap_Push(p_html_cache, file_path, cached);
+      }
     }
 
     if (!file_content)
@@ -219,11 +225,16 @@
     else if (strstr(file_path, ".js")) mime = "application/javascript";
     else if (strstr(file_path, ".png")) mime = "image/png";
     else if (strstr(file_path, ".jpg") || strstr(file_path, ".jpeg")) mime = "image/jpeg";
+    else if (strstr(file_path, ".webp")) mime = "image/webp";
     else if (strstr(file_path, ".gif")) mime = "image/gif";
     else if (strstr(file_path, ".svg")) mime = "image/svg+xml";
     else if (strstr(file_path, ".ico")) mime = "image/x-icon";
     else if (strstr(file_path, ".json")) mime = "application/json";
     else if (strstr(file_path, ".wasm")) mime = "application/wasm";
+    else if (strstr(file_path, ".mp4")) mime = "video/mp4";
+    else if (strstr(file_path, ".webm")) mime = "video/webm";
+    else if (strstr(file_path, ".glb")) mime = "model/gltf-binary";
+    else if (strstr(file_path, ".gltf")) mime = "model/gltf+json";
 
     Seobeo_Log(SEOBEO_DEBUG, "File path: %s\nBody Size: %zu\n", file_path, body_size);