#ifndef UTILS_HPP # define UTILS_HPP # include # include # include # include // atoi # include // stat() # define CR "\r" # define LF "\n" # define CRLF CR LF enum http_method { UNKNOWN = 0b0, GET = 1 << 0, POST = 1 << 1, DELETE = 1 << 2, ANY_METHODS = 0b11111111, // ALL_METHODS = 0b11111111, // i would prefer this... }; struct listen_socket { int fd; std::string host; std::string port; }; bool operator==(const listen_socket& lhs, int fd); bool operator==(int fd, const listen_socket& rhs); std::vector split(std::string input, char delimiter); bool isNumeric(std::string str); bool isNumeric_btw(int low, int high, std::string str); std::string itos(int n); std::string trim(std::string str, char c); http_method str_to_http_method(std::string &str); std::string http_methods_to_str(unsigned int methods); int path_is_valid(std::string path); void replace_all_substr(std::string &str, const std::string &ori_substr, const std::string &new_substr); void throw_test(); #endif