feat: parse method into enum value

This commit is contained in:
Jef Roosens 2023-05-28 09:09:46 +02:00
parent 90ff55d977
commit a90330dd6e
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
5 changed files with 50 additions and 10 deletions

View file

@ -15,6 +15,8 @@ extern const char http_405[];
extern const size_t http_405_len;
extern const char http_500[];
extern const size_t http_500_len;
extern const char http_501[];
extern const size_t http_501_len;
typedef enum http_request_method {
http_request_method_get = 0,
@ -24,14 +26,16 @@ typedef enum http_request_method {
http_request_method_delete = 4
} http_request_method;
extern const char *request_method_names[];
extern const size_t request_method_names_len;
/*
* Struct representing the specific type of request
*/
typedef struct http_request {
size_t len;
int minor_version;
const char *method;
size_t method_len;
http_request_method method;
const char *path;
size_t path_len;
const char *query;
@ -43,13 +47,15 @@ typedef enum http_parse_error {
http_parse_error_ok = 0,
http_parse_error_incomplete = 1,
http_parse_error_invalid = 2,
http_parse_error_unknown_method = 3
} http_parse_error;
/* void http_route(event_loop_conn *conn); */
typedef enum http_response_type {
http_not_found = 404,
http_method_not_allowed = 405
http_method_not_allowed = 405,
http_method_not_implemented = 501
} http_response_type;
void http_write_standard_response(event_loop_conn *conn,