fix http parser and config

This commit is contained in:
2025-05-08 16:58:42 +02:00
parent 8e880f59be
commit 8ff2bb608c
11 changed files with 50 additions and 35 deletions

View File

@@ -1,10 +1,9 @@
#ifndef CWS_HTTP_H
#define CWS_HTTP_H
#include "utils/config.h"
#include "utils/hashmap.h"
#define CWS_WWW "../www" /**< Directory used to get html files */
/** In the future I'll move conf stuff under a server struct, I can skip just because I want something that works */
#define CWS_HTTP_LOCATION_LEN 512
#define CWS_HTTP_LOCATION_PATH_LEN 1024
#define CWS_HTTP_VERSION_LEN 8
@@ -14,8 +13,8 @@ typedef enum cws_http_method_t {
CWS_HTTP_POST, /**< POST method */
CWS_HTTP_PUT,
CWS_HTTP_DELETE,
CWS_HTTP_HEAD,
} cws_http_method;
/* In the future I'll add HEAD, PUT, DELETE */
/**
* @brief HTTP request struct
@@ -39,7 +38,7 @@ typedef struct cws_http_t {
* @param[in] request_str The http request sent to the server
* @return Returns a http_t pointer to the request
*/
cws_http *cws_http_parse(char *request_str, int sockfd);
cws_http *cws_http_parse(char *request_str, int sockfd, cws_config *config);
void cws_http_parse_method(cws_http *request, const char *method);
void cws_http_get_content_type(cws_http *request, char *content_type);