feat: paved the way for uploading pastes
This commit is contained in:
parent
94b07caeb3
commit
dfbd179c7a
8 changed files with 96 additions and 77 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue