feat: add mime types

This commit is contained in:
Jef Roosens 2023-05-30 15:18:39 +02:00
parent 0d5c6d0f39
commit 89fb77db7f
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
7 changed files with 86 additions and 14 deletions

View file

@ -11,9 +11,19 @@
#define HTTP_MAX_ALLOWED_HEADERS 16
#define HTTP_MAX_REGEX_GROUPS 4
extern const char *http_response_type_names[5][32];
// Array mapping the http_response_type enum to strings
extern const char *http_response_type_names[][32];
// Array mapping the http_header enum to strings
extern const char *http_header_names[];
// Array mapping the http_mime_type enum to strings
extern const char *http_mime_type_names[][2];
// Array mapping the http_request_method enum to strings
extern const char *request_method_names[];
extern const size_t request_method_names_len;
typedef enum http_request_method {
http_get = 0,
http_post = 1,
@ -22,9 +32,6 @@ typedef enum http_request_method {
http_delete = 4
} http_request_method;
extern const char *request_method_names[];
extern const size_t request_method_names_len;
typedef enum http_body_type {
http_body_buf = 0,
http_body_file = 1
@ -132,7 +139,8 @@ typedef enum http_response_type {
typedef enum http_header {
http_header_connection = 0,
http_header_location = 1
http_header_location,
http_header_content_type
} http_header;
typedef struct http_response_header {
@ -159,4 +167,31 @@ typedef struct http_response {
size_t header_count;
} http_response;
typedef enum http_mime_type {
http_mime_aac = 0,
http_mime_bz,
http_mime_bz2,
http_mime_css,
http_mime_csv,
http_mime_gz,
http_mime_gif,
http_mime_htm,
http_mime_html,
http_mime_jar,
http_mime_jpeg,
http_mime_js,
http_mime_json,
http_mime_mp3,
http_mime_mp4,
http_mime_png,
http_mime_pdf,
http_mime_rar,
http_mime_sh,
http_mime_svg,
http_mime_tar,
http_mime_txt,
http_mime_wav,
http_mime_7z
} http_mime_type;
#endif

View file

@ -106,6 +106,8 @@ void http_loop_res_set_body_file(http_loop_ctx *ctx, const char *filename);
void http_loop_res_add_header(http_loop_ctx *ctx, http_header type,
const char *value, bool owned);
void http_loop_res_set_mime_type(http_loop_ctx *ctx, http_mime_type mime_type);
/*
* Request step that consumes the request body and stores it in a buffer
*/