mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
fix: delete client, if he empty
This commit is contained in:
@@ -149,7 +149,10 @@ std::string Client::generateRespons(void)
|
||||
|
||||
bool Client::readyToSend(void)
|
||||
{
|
||||
return(_request.ok());
|
||||
if (_request.ok())
|
||||
return(_request.ok());
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void Client::printClientInfo(void)
|
||||
@@ -183,6 +186,15 @@ void Client::printClientInfo(void)
|
||||
|
||||
}
|
||||
|
||||
bool Client::isEmpty(void)
|
||||
{
|
||||
if (!_request.ok() && _request.getHeaderSize() == 0
|
||||
&& _request.getContentLength() == 0)
|
||||
return (true);
|
||||
else
|
||||
return (false);
|
||||
}
|
||||
|
||||
void Client::clear(void)
|
||||
{
|
||||
_fd = -1;
|
||||
|
||||
@@ -37,8 +37,8 @@ public:
|
||||
void setRawData(char *);
|
||||
void setFd(int);
|
||||
int getFd(void);
|
||||
unsigned int getRecvCounter(void) const;
|
||||
|
||||
unsigned int getRecvCounter(void) const;
|
||||
bool isEmpty(void);
|
||||
|
||||
public:
|
||||
int parseRequest(void);
|
||||
|
||||
@@ -11,6 +11,7 @@ Request::Request()
|
||||
_head_ok = false;
|
||||
_body_ok = false;
|
||||
_received = 0;
|
||||
_headerSize = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +25,7 @@ Request::Request(char *str)
|
||||
_received = 0;
|
||||
_chunked = false;
|
||||
_contentLength = 0;
|
||||
_headerSize = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------Get/Set---------------------------------------
|
||||
|
||||
@@ -154,7 +154,7 @@ void Server::start(void)
|
||||
std::cout << TURQ << "IN SEND LOOP" << RESET << std::endl;
|
||||
Client &client = client_it->second;
|
||||
|
||||
if (!client.allRead)
|
||||
if (!client.allRead && !client.isEmpty())
|
||||
{
|
||||
readSocket(client_it->first, client_map);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ void Server::start(void)
|
||||
|
||||
}
|
||||
|
||||
if (client.readyToSend() && client.allSended())
|
||||
if ((client.readyToSend() && client.allSended()) || client.isEmpty())
|
||||
{
|
||||
client_map[fd].printClientInfo();
|
||||
close(client_it->first);
|
||||
|
||||
Reference in New Issue
Block a user