lander/include/http/req.h

43 lines
877 B
C

#ifndef LANDER_HTTP_REQ
#define LANDER_HTTP_REQ
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "http/types.h"
#include "picohttpparser.h"
#define HTTP_MAX_ALLOWED_HEADERS 16
#define HTTP_MAX_REGEX_GROUPS 4
/**
* Struct representing the specific type of request
*/
typedef struct http_request {
size_t len;
int minor_version;
http_method method;
const char *path;
size_t path_len;
const char *query;
size_t query_len;
http_body body;
regmatch_t regex_groups[HTTP_MAX_REGEX_GROUPS];
struct phr_header headers[HTTP_MAX_ALLOWED_HEADERS];
size_t num_headers;
} http_request;
/**
* Result of the HTTP parse function
*/
typedef enum http_parse_error {
http_parse_error_ok = 0,
http_parse_error_incomplete = 1,
http_parse_error_invalid = 2,
http_parse_error_unknown_method = 3
} http_parse_error;
#endif