ServerCore/Header.cpp
2019-05-21 16:41:07 -07:00

44 lines
997 B
C++

#include "Header.h"
#include "Log.h"
namespace core {
Header::Header(std::string data) : data(data) {
// Log(LOG_DEBUG_4) << data;
}
Header::~Header() {}
std::string Header::requestMethod() {
return data.substr(0, data.find(" "));
}
std::string Header::requestURL() {
std::string temp = data.substr(data.find(" ") + 1);
return temp.substr(0, temp.find(" "));
}
std::string Header::requestProtocol() {
std::string line1 = data.substr(0, data.find("\r\n"));
return line1.substr(line1.rfind(" ") + 1);
}
std::string Header::getPath() {
std::string temp = requestURL().substr(requestURL().find('/'));
return temp.substr(0, temp.find('?'));
}
std::string Header::getCGIData() {
return requestURL().substr(requestURL().find('?') + 1);
}
std::string Header::getCookie(std::string cookie) {
return "";
// TODO: Parse the header to retrieve the cookie data.
}
}