Mercurial
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 131:b230a743a01e | 132:7a63e41a21fb |
|---|---|
| 187 const char *file_content = NULL; | 187 const char *file_content = NULL; |
| 188 size_t body_size = 0; | 188 size_t body_size = 0; |
| 189 | 189 |
| 190 if (p_file_kv) | 190 if (p_file_kv) |
| 191 { | 191 { |
| 192 // File is cached | 192 // File is cached - use stored size for binary file support |
| 193 file_content = ((Seobeo_Cache_Entry*)p_file_kv)->value; | 193 Seobeo_Cached_File *cached = ((Seobeo_Cache_Entry*)p_file_kv)->value; |
| 194 body_size = strlen(file_content); | 194 file_content = cached->content; |
| 195 body_size = cached->size; | |
| 195 } | 196 } |
| 196 else | 197 else |
| 197 { | 198 { |
| 198 file_content = Seobeo_Web_LoadFile(file_path, &body_size); | 199 file_content = Seobeo_Web_LoadFile(file_path, &body_size); |
| 199 if (file_content) | 200 if (file_content) |
| 200 Dowa_HashMap_Push(p_html_cache, file_path, file_content); | 201 { |
| 202 Seobeo_Cached_File *cached = malloc(sizeof(Seobeo_Cached_File)); | |
| 203 cached->content = (char*)file_content; | |
| 204 cached->size = body_size; | |
| 205 Dowa_HashMap_Push(p_html_cache, file_path, cached); | |
| 206 } | |
| 201 } | 207 } |
| 202 | 208 |
| 203 if (!file_content) | 209 if (!file_content) |
| 204 { | 210 { |
| 205 Seobeo_Web_Header_Generate(p_response_header, | 211 Seobeo_Web_Header_Generate(p_response_header, |
| 217 if (strstr(file_path, ".html")) mime = "text/html; charset=utf-8"; | 223 if (strstr(file_path, ".html")) mime = "text/html; charset=utf-8"; |
| 218 else if (strstr(file_path, ".css")) mime = "text/css"; | 224 else if (strstr(file_path, ".css")) mime = "text/css"; |
| 219 else if (strstr(file_path, ".js")) mime = "application/javascript"; | 225 else if (strstr(file_path, ".js")) mime = "application/javascript"; |
| 220 else if (strstr(file_path, ".png")) mime = "image/png"; | 226 else if (strstr(file_path, ".png")) mime = "image/png"; |
| 221 else if (strstr(file_path, ".jpg") || strstr(file_path, ".jpeg")) mime = "image/jpeg"; | 227 else if (strstr(file_path, ".jpg") || strstr(file_path, ".jpeg")) mime = "image/jpeg"; |
| 228 else if (strstr(file_path, ".webp")) mime = "image/webp"; | |
| 222 else if (strstr(file_path, ".gif")) mime = "image/gif"; | 229 else if (strstr(file_path, ".gif")) mime = "image/gif"; |
| 223 else if (strstr(file_path, ".svg")) mime = "image/svg+xml"; | 230 else if (strstr(file_path, ".svg")) mime = "image/svg+xml"; |
| 224 else if (strstr(file_path, ".ico")) mime = "image/x-icon"; | 231 else if (strstr(file_path, ".ico")) mime = "image/x-icon"; |
| 225 else if (strstr(file_path, ".json")) mime = "application/json"; | 232 else if (strstr(file_path, ".json")) mime = "application/json"; |
| 226 else if (strstr(file_path, ".wasm")) mime = "application/wasm"; | 233 else if (strstr(file_path, ".wasm")) mime = "application/wasm"; |
| 234 else if (strstr(file_path, ".mp4")) mime = "video/mp4"; | |
| 235 else if (strstr(file_path, ".webm")) mime = "video/webm"; | |
| 236 else if (strstr(file_path, ".glb")) mime = "model/gltf-binary"; | |
| 237 else if (strstr(file_path, ".gltf")) mime = "model/gltf+json"; | |
| 227 | 238 |
| 228 Seobeo_Log(SEOBEO_DEBUG, "File path: %s\nBody Size: %zu\n", file_path, body_size); | 239 Seobeo_Log(SEOBEO_DEBUG, "File path: %s\nBody Size: %zu\n", file_path, body_size); |
| 229 | 240 |
| 230 Seobeo_Web_Header_Generate(p_response_header, | 241 Seobeo_Web_Header_Generate(p_response_header, |
| 231 HTTP_OK, | 242 HTTP_OK, |