#ifndef SERVERUTILS_H #define SERVERUTILS_H #include #include #include "../include/DataType.h" #include "../include/Track.h" #include "../include/ConcurrentQueue.h" #include "../include/Options.h" using namespace std; class ServerUtils { public: static void serve(shared_ptr> cq_track, const Options& options); private: static void process_request(int client_fd); static void send_html(int client_fd, size_t hash); static void send_css(int client_fd); static void send_data(int client_fd, const string& data); static void send_image(int client_fd, const string& path, image_type type); static uint32_t get_ip(int client_fd); }; const string HTML_RESPONSE_HEADER = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html; charset=utf-8\r\n" "Cache-control: max-age=12000\r\n" "Connection: close\r\n\r\n"; const string CSS_RESPONSE_HEADER = "HTTP/1.1 200 OK\r\n" "Content-Type: text/css; charset=utf-8\r\n" "Cache-control: max-age=12000\r\n" "Connection: close\r\n\r\n"; const string HTML_BEGINNING = "\n\r\n" "Drip\r\n" "\r\n" "\r\n" "\r\n"; const string HTML_END = "\r\n"; const string HTML_NAV = "
\r\n" "
\r\n" "\r\n" "
\r\n"; const string HTML_MAIN_1 = "
\r\n" "
\r\n"; const string HTML_MAIN_2 = "
\r\n" "
\r\n"; const string HTML_FOOTER = "\r\n" "
\r\n"; #endif