mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 13:27: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)
|
bool Client::readyToSend(void)
|
||||||
{
|
{
|
||||||
|
if (_request.ok())
|
||||||
return(_request.ok());
|
return(_request.ok());
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::printClientInfo(void)
|
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)
|
void Client::clear(void)
|
||||||
{
|
{
|
||||||
_fd = -1;
|
_fd = -1;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
void setFd(int);
|
void setFd(int);
|
||||||
int getFd(void);
|
int getFd(void);
|
||||||
unsigned int getRecvCounter(void) const;
|
unsigned int getRecvCounter(void) const;
|
||||||
|
bool isEmpty(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int parseRequest(void);
|
int parseRequest(void);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Request::Request()
|
|||||||
_head_ok = false;
|
_head_ok = false;
|
||||||
_body_ok = false;
|
_body_ok = false;
|
||||||
_received = 0;
|
_received = 0;
|
||||||
|
_headerSize = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ Request::Request(char *str)
|
|||||||
_received = 0;
|
_received = 0;
|
||||||
_chunked = false;
|
_chunked = false;
|
||||||
_contentLength = 0;
|
_contentLength = 0;
|
||||||
|
_headerSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------Get/Set---------------------------------------
|
//-------------------------------------------------Get/Set---------------------------------------
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ void Server::start(void)
|
|||||||
std::cout << TURQ << "IN SEND LOOP" << RESET << std::endl;
|
std::cout << TURQ << "IN SEND LOOP" << RESET << std::endl;
|
||||||
Client &client = client_it->second;
|
Client &client = client_it->second;
|
||||||
|
|
||||||
if (!client.allRead)
|
if (!client.allRead && !client.isEmpty())
|
||||||
{
|
{
|
||||||
readSocket(client_it->first, client_map);
|
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();
|
client_map[fd].printClientInfo();
|
||||||
close(client_it->first);
|
close(client_it->first);
|
||||||
|
|||||||
Reference in New Issue
Block a user