refactor(req/res): new request/response structure

This commit is contained in:
2026-01-14 02:19:08 +01:00
parent b083c264b8
commit f195bf4202
9 changed files with 380 additions and 166 deletions

View File

@@ -1,6 +1,7 @@
#ifndef CWS_REQUEST_H
#define CWS_REQUEST_H
#include "http/types.h"
#include <myclib/myhashmap.h>
#include <myclib/mystring.h>
#include <stddef.h>
@@ -9,28 +10,13 @@
#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_request {
int sockfd;
cws_http_method_e method;
string_s *location;
string_s *location_path;
string_s *path;
string_s *query_string;
string_s *http_version;
hashmap_s *headers;
string_s *body;
} cws_request_s;
cws_request_s *cws_http_parse(string_s *request_str);