comparison seobeo/seobeo.h @ 119:c39582f937e5

[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
author June Park <parkjune1995@gmail.com>
date Wed, 07 Jan 2026 16:05:57 -0800
parents 70401cf61e97
children cbbf78b17cfa
comparison
equal deleted inserted replaced
118:249881ceff7b 119:c39582f937e5
8 * Library for starting TCP, UDP server and serving static file or path. 8 * Library for starting TCP, UDP server and serving static file or path.
9 */ 9 */
10 10
11 #include "seobeo/seobeo_internal.h" 11 #include "seobeo/seobeo_internal.h"
12 12
13 /* Included in dowa
14 #include <stdio.h>
15 #include <stdlib.h>
16 */
17 #include <stdarg.h> 13 #include <stdarg.h>
18 #include <unistd.h> 14 #include <unistd.h>
19 #include <errno.h> 15 #include <errno.h>
20 #include <string.h> 16 #include <string.h>
21 #include <sys/types.h> 17 #include <sys/types.h>
68 extern void Seobeo_Web_Header_Generate(void *buffer, int status, const char *content_type, const int content_length); 64 extern void Seobeo_Web_Header_Generate(void *buffer, int status, const char *content_type, const int content_length);
69 /* Start a Generic HTTP static file server with given folder. It will store folder into memory. */ 65 /* Start a Generic HTTP static file server with given folder. It will store folder into memory. */
70 extern int Seobeo_Web_Server_Start(const char *folder_path, const char *port, Seobeo_ServerMode mode, int thread_count); 66 extern int Seobeo_Web_Server_Start(const char *folder_path, const char *port, Seobeo_ServerMode mode, int thread_count);
71 /* Generic HTTP GET Rquest to given host and port with path. It will mimic chrome. */ 67 /* Generic HTTP GET Rquest to given host and port with path. It will mimic chrome. */
72 extern int Seobeo_Web_Client_Get(const char *host, const char *port, const char *path); 68 extern int Seobeo_Web_Client_Get(const char *host, const char *port, const char *path);
69
70 // --- HTTP Client (curl-like API) --- //
71 /* Create a new HTTP client request with the given URL. */
72 extern Seobeo_Client_Request *Seobeo_Client_Request_Create(const char *url);
73 /* Set HTTP method (GET, POST, PUT, DELETE, etc.). Default is GET. */
74 extern void Seobeo_Client_Request_Set_Method(Seobeo_Client_Request *p_req, const char *method);
75 /* Add a header using key-value pairs (stored in HashMap). */
76 extern void Seobeo_Client_Request_Add_Header_Map(Seobeo_Client_Request *p_req, const char *key, const char *value);
77 /* Add a header as a string "Key: Value" (stored in Array). */
78 extern void Seobeo_Client_Request_Add_Header_Array(Seobeo_Client_Request *p_req, const char *header);
79 /* Set request body with given data and length. */
80 extern void Seobeo_Client_Request_Set_Body(Seobeo_Client_Request *p_req, const char *body, size_t length);
81 /* Enable/disable following redirects with max redirect count. Default is FALSE with 10 max. */
82 extern void Seobeo_Client_Request_Set_Follow_Redirects(Seobeo_Client_Request *p_req, boolean follow, int32 max_redirects);
83 /* Set download path to save response body to file instead of memory. */
84 extern void Seobeo_Client_Request_Set_Download_Path(Seobeo_Client_Request *p_req, const char *path);
85 /* Execute the HTTP request and return response. */
86 extern Seobeo_Client_Response *Seobeo_Client_Request_Execute(Seobeo_Client_Request *p_req);
87 /* Destroy request and free all resources. */
88 extern void Seobeo_Client_Request_Destroy(Seobeo_Client_Request *p_req);
89 /* Destroy response and free all resources. */
90 extern void Seobeo_Client_Response_Destroy(Seobeo_Client_Response *p_resp);
73 /* Initialize the router system (called automatically by Seobeo_Web_Server_Start) */ 91 /* Initialize the router system (called automatically by Seobeo_Web_Server_Start) */
74 extern void Seobeo_Router_Init(); 92 extern void Seobeo_Router_Init();
75 /* Register an API route handler. Call before starting server. */ 93 /* Register an API route handler. Call before starting server. */
76 extern void Seobeo_Router_Register(const char *method, const char *path_pattern, Seobeo_Route_Handler handler); 94 extern void Seobeo_Router_Register(const char *method, const char *path_pattern, Seobeo_Route_Handler handler);
77 /* Clean up router resources */ 95 /* Clean up router resources */