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

@ -40,7 +40,8 @@ void http_loop_ctx_reset(http_loop_ctx *ctx) {
ctx->res.head = NULL;
}
if (ctx->res.body_type == http_body_buf && ctx->res.body.buf != NULL) {
if (ctx->res.body_type == http_body_buf && ctx->res.body.buf != NULL &&
ctx->res.owns_body) {
free(ctx->res.body.buf);
ctx->res.body.buf = NULL;
} else if (ctx->res.body_type == http_body_file &&

View file

@ -30,3 +30,8 @@ void http_loop_res_add_header(http_loop_ctx *ctx, http_header type,
ctx->res.header_count++;
}
void http_loop_res_set_mime_type(http_loop_ctx *ctx, http_mime_type mime_type) {
http_loop_res_add_header(ctx, http_header_content_type,
http_mime_type_names[mime_type][1], false);
}