Rewrite middleware to support epoll
This commit is contained in:
@@ -17,31 +17,30 @@ namespace Http
|
||||
return static_cast<T>(-1);
|
||||
}
|
||||
|
||||
Http::Request Request::Deserialize(std::vector<char> const & bytes)
|
||||
void Request::Deserialize(std::vector<char> const & bytes, Logger & logger)
|
||||
{
|
||||
// TODO serialize more than just the start
|
||||
Http::Request request;
|
||||
|
||||
std::stringstream ss(std::string(bytes.begin(), bytes.end()));
|
||||
|
||||
std::string requestTypeString;
|
||||
ss >> requestTypeString;
|
||||
request.type = ToEnum<HttpRequest::Type>(requestTypeString, HttpRequest::typeStrings);
|
||||
if (request.type == HttpRequest::Type::UNKNOWN)
|
||||
type = ToEnum<HttpRequest::Type>(requestTypeString, HttpRequest::typeStrings);
|
||||
if (type == HttpRequest::Type::UNKNOWN)
|
||||
{
|
||||
throw std::runtime_error("Bad request type");
|
||||
logger.Error("Request::Deserialize: Bad request type");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string rawUrl;
|
||||
ss >> rawUrl;
|
||||
if(!request.url.TryParseFromUrlString(rawUrl))
|
||||
if(!url.TryParseFromUrlString(rawUrl))
|
||||
{
|
||||
throw std::runtime_error("Bad url in request");
|
||||
logger.Error("Request::Deserialize: Bad url in request");
|
||||
type = HttpRequest::Type::UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string httpProtocolString;
|
||||
ss >> httpProtocolString;
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user