#ifndef HTTP #define HTTP #include #include "picohttpparser.h" #include "event_loop.h" #define HTTP_MAX_ALLOWED_HEADERS 8 extern const char http_404[]; extern const size_t http_404_len; extern const char http_405[]; extern const size_t http_405_len; extern const char http_500[]; extern const size_t http_500_len; extern const char http_501[]; extern const size_t http_501_len; typedef enum http_request_method { http_request_method_get = 0, http_request_method_post = 1, http_request_method_put = 2, http_request_method_patch = 3, http_request_method_delete = 4 } http_request_method; extern const char *request_method_names[]; extern const size_t request_method_names_len; /* * Struct representing the specific type of request */ typedef struct http_request { size_t len; int minor_version; http_request_method method; const char *path; size_t path_len; const char *query; size_t query_len; struct phr_header headers[HTTP_MAX_ALLOWED_HEADERS]; } http_request; 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; /* void http_route(event_loop_conn *conn); */ typedef enum http_response_type { http_not_found = 404, http_method_not_allowed = 405, http_method_not_implemented = 501 } http_response_type; void http_write_standard_response(event_loop_conn *conn, http_response_type type); #endif