Add win socket client and server.
This commit is contained in:
parent
426ea55b3b
commit
4d2464c1f5
45 changed files with 1167 additions and 246 deletions
43
src/base/core/http/HttpParser.cpp
Normal file
43
src/base/core/http/HttpParser.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "HttpParser.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
bool HttpParser::parsePreamble(const std::string& line, HttpPreamble& preamble)
|
||||
{
|
||||
bool inPath{ false };
|
||||
bool inMethod{ true };
|
||||
bool inProtocol{ false };
|
||||
|
||||
for (const auto c : line)
|
||||
{
|
||||
if (inPath)
|
||||
{
|
||||
if (StringUtils::isSpace(c))
|
||||
{
|
||||
inPath = false;
|
||||
inMethod = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
preamble.mPath.push_back(c);
|
||||
}
|
||||
}
|
||||
else if (inMethod)
|
||||
{
|
||||
if (StringUtils::isSpace(c))
|
||||
{
|
||||
inMethod = false;
|
||||
inProtocol = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
preamble.mMethod.push_back(c);
|
||||
}
|
||||
}
|
||||
else if (inProtocol)
|
||||
{
|
||||
preamble.mVersion.push_back(c);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue