lander/src/http/types.c

34 lines
592 B
C

#include <stdlib.h>
#include "http/types.h"
http_body *http_body_init() { return calloc(sizeof(http_body), 1); }
void http_body_reset(http_body *body) {
if (body->type == http_body_file) {
fclose(body->file);
}
if (body->buf_owned) {
free(body->buf);
}
if (body->fname_owned) {
free(body->fname);
}
body->type = 0;
body->buf = NULL;
body->buf_owned = false;
body->file = NULL;
body->fname = NULL;
body->fname_owned = false;
body->expected_len = 0;
body->len = 0;
}
void http_body_free(http_body *body) {
http_body_reset(body);
free(body);
}