site.cpp (693B)
1 #include "../include/site.hpp" 2 3 #include <algorithm> 4 #include <cstdint> 5 #include <string> 6 7 Site::Site(std::string h, std::string b) : body(b), header(h) {} 8 9 std::string Site::getHeader() { return header; } 10 11 std::string Site::getBody() { return body; } 12 uint32_t Site::getStatusCode() { 13 try { 14 uint32_t statusCode = std::stoi(header.substr(0, 2)); 15 return statusCode; 16 } catch (...) { 17 return uint32_t{41}; 18 } 19 } 20 21 std::string Site::getMeta() { 22 std::string meta = header.substr(3); 23 std::replace(meta.begin(), meta.end(), '\n', ' '); 24 return meta; 25 } 26 27 void Site::setUnreachable() { unreachable = true; } 28 29 bool Site::getUnreachable() { return unreachable; }