refactor: change project structure

This commit is contained in:
2025-10-26 17:51:41 +01:00
parent 33a12aaf73
commit 0293b0f5c0
25 changed files with 585 additions and 555 deletions

45
include/http/request.h Normal file
View File

@@ -0,0 +1,45 @@
#ifndef CWS_HTTP_H
#define CWS_HTTP_H
#include <myclib/myhashmap.h>
#include <myclib/mystring.h>
#include <stddef.h>
#define CWS_HTTP_CONTENT_TYPE 64
#define CWS_HTTP_HEADER_MAX 512
#define CWS_HTTP_HEADER_CONTENT_MAX 1024
typedef enum cws_http_method {
HTTP_GET,
HTTP_POST,
HTTP_PUT,
HTTP_DELETE,
HTTP_HEAD,
HTTP_UNKNOWN,
} cws_http_method_e;
typedef enum cws_http_status {
HTTP_OK,
HTTP_NOT_FOUND,
HTTP_NOT_IMPLEMENTED,
} cws_http_status_e;
typedef struct cws_http {
int sockfd;
cws_http_method_e method;
string_s *location;
string_s *location_path;
string_s *http_version;
hashmap_s *headers;
} cws_http_s;
cws_http_s *cws_http_parse(string_s *request_str);
void cws_http_send_response(cws_http_s *request, cws_http_status_e status);
size_t http_response_builder(char **response, cws_http_status_e status, char *content_type,
char *body, size_t body_len_bytes);
void cws_http_free(cws_http_s *request);
#endif