Use epoll facilities
This commit is contained in:
@@ -6,22 +6,9 @@
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
void ConnectionOperator::SendResponse(ClientSocket const & clientSocket, Http::Response const & response) const
|
||||
std::vector<char> ConnectionOperator::HandleNewConnection(int fd)
|
||||
{
|
||||
auto bytesToSend = response.Serialize();
|
||||
try
|
||||
{
|
||||
clientSocket.WriteBytes(bytesToSend);
|
||||
}
|
||||
catch(std::runtime_error & e)
|
||||
{
|
||||
logger.Error("Error writing data to clientSocket");
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionOperator::HandleNewConnection(ClientSocket const & newClient)
|
||||
{
|
||||
auto requestBytes = newClient.ReadBytes();
|
||||
auto requestBytes = Socket::ReadBytes(fd, 512);
|
||||
Http::Request request;
|
||||
Http::Response response;
|
||||
try
|
||||
@@ -37,8 +24,8 @@ void ConnectionOperator::HandleNewConnection(ClientSocket const & newClient)
|
||||
logger.Error(ss.str());
|
||||
|
||||
response.code = HttpResponse::Code::BAD_REQUEST;
|
||||
SendResponse(newClient, response);
|
||||
return;
|
||||
|
||||
return response.Serialize();
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < middlewares.size(); ++i)
|
||||
@@ -57,12 +44,11 @@ void ConnectionOperator::HandleNewConnection(ClientSocket const & newClient)
|
||||
logger.Error(ss.str());
|
||||
|
||||
response.code = HttpResponse::Code::NOT_IMPLEMENTED;
|
||||
SendResponse(newClient, response);
|
||||
return;
|
||||
|
||||
return response.Serialize();
|
||||
}
|
||||
|
||||
auto bytesToSend = response.Serialize();
|
||||
newClient.WriteBytes(bytesToSend);
|
||||
return response.Serialize();
|
||||
}
|
||||
|
||||
ConnectionOperator::ConnectionOperator(Logger & _logger, ServerConfiguration const & serverConfiguration)
|
||||
|
||||
Reference in New Issue
Block a user