lander/include/http/res.h

49 lines
1.1 KiB
C
Raw Normal View History

#ifndef LANDER_HTTP_RES
#define LANDER_HTTP_RES
#include <stdbool.h>
#include <stdio.h>
#include "http/types.h"
typedef struct http_response_header {
http_header type;
const char *value;
bool owned;
} http_response_header;
typedef struct http_response {
http_status status;
const char *head;
size_t head_len;
size_t head_written;
2023-05-31 11:46:34 +02:00
http_body body;
http_response_header headers[4];
size_t header_count;
} http_response;
/*
* Set the request body to the given buffer. If owned is set to true, the body
* buffer will be free'd after the request has finished.
*/
void http_res_set_body_buf(http_response *res, const char *body,
size_t body_len, bool owned);
/*
* Set the request body to the given filename.
*/
void http_res_set_body_file(http_response *res, const char *filename);
/*
* Add a header to the response.
*/
void http_res_add_header(http_response *res, http_header type,
const char *value, bool owned);
/*
* Add a Content-Type header corresponding to the mime type.
*/
void http_res_set_mime_type(http_response *res, http_mime_type mime_type);
#endif