Small cleaning.

This commit is contained in:
James Grogan 2022-12-04 18:13:32 +00:00
parent 70220fc6e9
commit d7fe11913f
26 changed files with 613 additions and 548 deletions

View file

@ -6,63 +6,63 @@
void HttpRequest::parseMessage(const std::string& message)
{
std::stringstream ss(message);
std::stringstream ss(message);
std::string buffer;
bool firstLine {true};
std::string buffer;
bool firstLine {true};
std::vector<std::string> headers;
while(std::getline(ss, buffer, '\n'))
{
if (firstLine)
{
parseFirstLine(buffer);
firstLine = false;
}
else
{
headers.push_back(buffer);
}
}
mHeader.parse(headers);
std::vector<std::string> headers;
while(std::getline(ss, buffer, '\n'))
{
if (firstLine)
{
parseFirstLine(buffer);
firstLine = false;
}
else
{
headers.push_back(buffer);
}
}
mHeader.parse(headers);
}
void HttpRequest::parseFirstLine(const std::string& line)
{
bool inPath{false};
bool inMethod{true};
bool inProtocol{false};
bool inPath{false};
bool inMethod{true};
bool inProtocol{false};
for (std::size_t idx=0; idx<line.size();idx++)
{
const auto c = line[idx];
if (inPath)
{
if (StringUtils::IsSpace(c))
{
inPath = false;
inMethod = true;
}
else
{
mMethod.push_back(c);
}
}
else if (inMethod)
{
if (StringUtils::IsSpace(c))
{
inMethod = false;
inProtocol = true;
}
else
{
mPath.push_back(c);
}
}
else if (inProtocol)
{
mProtocolVersion.push_back(c);
}
}
for (std::size_t idx=0; idx<line.size();idx++)
{
const auto c = line[idx];
if (inPath)
{
if (StringUtils::IsSpace(c))
{
inPath = false;
inMethod = true;
}
else
{
mMethod.push_back(c);
}
}
else if (inMethod)
{
if (StringUtils::IsSpace(c))
{
inMethod = false;
inProtocol = true;
}
else
{
mPath.push_back(c);
}
}
else if (inProtocol)
{
mProtocolVersion.push_back(c);
}
}
}