#include "Helpers.hpp" #include #include #include // Should add caching here std::string Helpers::ReadFile(std::string Path) { std::ifstream file(Path); std::stringstream contents; contents << file.rdbuf(); file.close(); return contents.str(); } void Helpers::getlineAndCount(std::basic_istream &stream, uint64_t &count, std::string &string, char delimit) { if (delimit == '\0') { std::getline(stream, string); } else { std::getline(stream, string, delimit); } count += string.size() + 1; // Delimiter return; } std::string Helpers::GenerateResponse(std::string statusCode, std::string contentType, std::string content) { std::stringstream output; output << "HTTP/1.1 " << statusCode << "\n" << "Content-Type: " << contentType << "\nContent-Length: " << content.size() << "\nConnection: close\n\n" << content; return output.str(); }