Mercurial
diff seobeo/s_router.c @ 92:655ea0b661fd
[Seobeo] Added few endpoints for handling files. [Dowa] Added few functions for random number and generating uuids
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 02 Jan 2026 17:47:10 -0800 |
| parents | 5710108c949e |
| children |
line wrap: on
line diff
--- a/seobeo/s_router.c Thu Jan 01 16:34:51 2026 -0800 +++ b/seobeo/s_router.c Fri Jan 02 17:47:10 2026 -0800 @@ -150,15 +150,25 @@ content_type = ((Seobeo_Request_Entry*)p_content_type_kv)->value; } + // Check for custom content-length (for binary data) + size_t body_length = strlen(body); + void *p_content_length_kv = Dowa_HashMap_Get_Ptr(p_response_map, "content-length"); + if (p_content_length_kv) + { + const char *content_length_str = ((Seobeo_Request_Entry*)p_content_length_kv)->value; + body_length = atoi(content_length_str); + } + // All other types are default thoguht to be headers. char *header = Dowa_Arena_Allocate(p_arena, 4096); - Seobeo_Web_Header_Generate(header, status, content_type, strlen(body)); + Seobeo_Web_Header_Generate(header, status, content_type, body_length); for (int i = 0; i < Dowa_Array_Length(p_response_map); i++) { if ( strstr(p_response_map[i].key, "status") || strstr(p_response_map[i].key, "body") || - strstr(p_response_map[i].key, "content-type") + strstr(p_response_map[i].key, "content-type") || + strstr(p_response_map[i].key, "content-length") // Skip custom content-length ) continue; @@ -170,7 +180,7 @@ } Seobeo_Handle_Queue(p_handle, (uint8_t*)header, strlen(header)); - Seobeo_Handle_Queue(p_handle, (uint8_t*)body, strlen(body)); + Seobeo_Handle_Queue(p_handle, (uint8_t*)body, body_length); // Use actual body length Seobeo_Handle_Flush(p_handle); }