fix: leak in Response class

This commit is contained in:
Talyx
2022-02-18 18:12:01 +03:00
parent 28c86e5e43
commit 1519914e97
5 changed files with 19 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ Request::Request()
_received = 0;
_headerSize = 0;
_lifeTime = 5;
_body = new std::string;
_body = NULL;
}
Request::Request(char *str)
@@ -28,12 +28,17 @@ Request::Request(char *str)
_contentLength = 0;
_headerSize = 0;
_lifeTime = 5;
_body = new std::string;
_body = NULL;
}
//-------------------------------------------------Get/Set---------------------------------------
void Request::freeData(void)
{
delete _body;
}
std::string &Request::getURI(void)
{
return (_URI);
@@ -226,11 +231,13 @@ void Request::splitData(std::string &data)
if ((_contentLength == 0 && !_chunked) || (_method == "GET"
|| _method == "DELETE" || _method == "HEAD"))
_body_ok = true;
else
_body = new std::string;
}
}
if (badCode(_ret))
return ;
else if (_chunked)
else if (_chunked && !_body_ok)
{
_body->insert(_body->end(), str.begin(), str.end());
if (checkEnd(*_body, "0\r\n\r\n") == 0)