fix: linux tester

This commit is contained in:
Talyx
2022-02-10 00:36:34 +03:00
parent adbe832b98
commit 9b3b3bebca
4 changed files with 19 additions and 25 deletions

View File

@@ -184,22 +184,15 @@ void Request::splitData(std::string &data)
str = std::string(data);
if (!_head_ok)
{
pos = str.find("\r\n\r\n");
/* if (pos == -1) */
/* { */
/* _ret = 400; */
/* return; */
/* } */
DBOUT << RED << "pos is " << pos << ENDL;
if (pos == -1)
_head.insert(_head.end(), str.begin(), str.end());
pos = _head.find("\r\n\r\n");
if (pos != -1)
{
_head += str;
}
else
{
_head += str.substr(0, pos) + "\n";
_headerSize = _head.size() + 3;
data.erase(0, pos + 4);
std::string tmp;
tmp = _head.substr(0, pos) + "\n";
_headerSize = tmp.size() + 3;
str = _head.substr(_headerSize);
_head = tmp;
_head_ok = true;
parseHeader();
@@ -211,14 +204,13 @@ void Request::splitData(std::string &data)
return ;
else if (_chunked)
{
_body.insert(_body.end(), data.begin(), data.end());
_body.insert(_body.end(), str.begin(), str.end());
if (checkEnd(_body, "0\r\n\r\n") == 0)
_body_ok = true;
}
else if (!_body_ok)
else if (_head_ok && !_body_ok)
{
_body.insert(_body.end(), data.begin(), data.end());
_body.insert(_body.end(), str.begin(), str.end());
if ((_received - _headerSize) == _contentLength)
{
_body_ok = true;

View File

@@ -214,7 +214,7 @@ std::string Response::getFullURI(void)
ret = tmp;
else
{
ret = tmp + _location->directoryFile;
ret = tmp + "/" + _location->directoryFile;
}
}
else
@@ -256,8 +256,10 @@ bool Response::allowedMethod(std::string &method)
{
if (*it == method)
return (true);
DBOUT << BLUE << *it << ENDL;
it++;
}
DBOUT << "location " << _location->location << ENDL;
_code = 405;
return (false);