feat: paved the way for uploading pastes

This commit is contained in:
Jef Roosens 2023-05-30 09:37:40 +02:00
parent 94b07caeb3
commit dfbd179c7a
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
8 changed files with 96 additions and 77 deletions

View file

@ -3,6 +3,7 @@
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "picohttpparser.h"
@ -24,6 +25,11 @@ typedef enum 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
} http_body_type;
/*
* Struct representing the specific type of request
*/
@ -35,7 +41,11 @@ typedef struct http_request {
size_t path_len;
const char *query;
size_t query_len;
char *body;
http_body_type body_type;
union {
char *buf;
FILE *file;
} body;
size_t body_len;
size_t body_received;
regmatch_t regex_groups[HTTP_MAX_REGEX_GROUPS];
@ -130,18 +140,16 @@ typedef struct http_response_header {
bool owned;
} http_response_header;
typedef enum http_response_body_type {
http_response_body_buf = 0,
http_response_body_file = 1
} http_response_body_type;
typedef struct http_response {
http_response_type status;
const char *head;
size_t head_len;
size_t head_written;
http_response_body_type body_type;
void *body;
http_body_type body_type;
union {
char *buf;
FILE *file;
} body;
size_t body_len;
size_t body_written;
// If false, the body won't be freed

View file

@ -5,6 +5,10 @@
extern http_route lander_routes[3];
bool lander_get_index(event_loop_conn *conn);
bool lander_get_entry(event_loop_conn *conn);
bool lander_post_redirect(event_loop_conn *conn);
#endif