(http server) read body request when the Content-Length is specified + set timeout to read the request to 30 seconds max by default, and make it configurable as a constructor parameter

This commit is contained in:
Benjamin Sergeant
2020-09-12 14:17:06 -07:00
parent b04e5c5529
commit 128bc0afa9
6 changed files with 21 additions and 9 deletions

View File

@ -92,10 +92,17 @@ namespace
namespace ix
{
HttpServer::HttpServer(
int port, const std::string& host, int backlog, size_t maxConnections, int addressFamily)
const int HttpServer::kDefaultTimeoutSecs(30);
HttpServer::HttpServer(int port,
const std::string& host,
int backlog,
size_t maxConnections,
int addressFamily,
int timeoutSecs)
: SocketServer(port, host, backlog, maxConnections, addressFamily)
, _connectedClientsCount(0)
, _timeoutSecs(timeoutSecs)
{
setDefaultConnectionCallback();
}
@ -124,7 +131,7 @@ namespace ix
{
_connectedClientsCount++;
auto ret = Http::parseRequest(socket);
auto ret = Http::parseRequest(socket, _timeoutSecs);
// FIXME: handle errors in parseRequest
if (std::get<0>(ret))