feat: add step to receive request body in buffer

This commit is contained in:
Jef Roosens 2023-05-29 23:26:15 +02:00
parent ff0795bb55
commit 16103f9b24
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
10 changed files with 113 additions and 12 deletions

View file

@ -35,8 +35,12 @@ typedef struct http_request {
size_t path_len;
const char *query;
size_t query_len;
char *body;
size_t body_len;
size_t body_received;
regmatch_t regex_groups[HTTP_MAX_REGEX_GROUPS];
struct phr_header headers[HTTP_MAX_ALLOWED_HEADERS];
size_t num_headers;
} http_request;
typedef enum http_parse_error {

View file

@ -7,6 +7,9 @@
#include "http.h"
#include "trie.h"
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
typedef enum http_route_type {
http_route_literal = 0,
http_route_regex = 1,
@ -102,6 +105,11 @@ 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);
/*
* Request step that consumes the request body and stores it in a buffer
*/
bool http_loop_step_body_to_buf(event_loop_conn *conn);
/**
* Initialize a new http loop
*/

View file

@ -3,6 +3,8 @@
#include "http_loop.h"
extern http_route lander_routes[2];
extern http_route lander_routes[3];
bool lander_post_redirect(event_loop_conn *conn);
#endif