mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 13:27:59 +03:00
add: limit from body size
This commit is contained in:
@@ -217,6 +217,10 @@ void Client::printClientInfo(void)
|
|||||||
std::cout << GREEN << "request http versioin = " << _request.getVersion() << ZERO_C << std::endl;
|
std::cout << GREEN << "request http versioin = " << _request.getVersion() << ZERO_C << std::endl;
|
||||||
std::cout << GREEN << "content-length = " << _request.getContentLength() << ZERO_C << std::endl;
|
std::cout << GREEN << "content-length = " << _request.getContentLength() << ZERO_C << std::endl;
|
||||||
std::cout << GREEN << "connection type = " << _request.getConnection() << ZERO_C << std::endl;
|
std::cout << GREEN << "connection type = " << _request.getConnection() << ZERO_C << std::endl;
|
||||||
|
it = map.find("transfer-encoding");
|
||||||
|
if (it != map.end())
|
||||||
|
std::cout << GREEN << "transfer-encoding = " << it->second << ZERO_C << std::endl;
|
||||||
|
|
||||||
|
|
||||||
std::cout << BLUE << std::endl << "RESPONSE" << ZERO_C << std::endl << std::endl;
|
std::cout << BLUE << std::endl << "RESPONSE" << ZERO_C << std::endl << std::endl;
|
||||||
std::cout << GREEN << _response.getHeader() << ZERO_C << std::endl;
|
std::cout << GREEN << _response.getHeader() << ZERO_C << std::endl;
|
||||||
|
|||||||
@@ -196,7 +196,8 @@ void Request::splitData(std::string &data)
|
|||||||
_head_ok = true;
|
_head_ok = true;
|
||||||
|
|
||||||
parseHeader();
|
parseHeader();
|
||||||
if (_contentLength == 0 && !_chunked)
|
if ((_contentLength == 0 && !_chunked) || (_method == "GET"
|
||||||
|
|| _method == "DELETE" || _method == "HEAD"))
|
||||||
_body_ok = true;
|
_body_ok = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,6 @@ std::string Response::getTime(void)
|
|||||||
|
|
||||||
std::string Response::getFullURI(void)
|
std::string Response::getFullURI(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
std::string ret = "";
|
std::string ret = "";
|
||||||
int len = _location->location.size();
|
int len = _location->location.size();
|
||||||
@@ -210,8 +209,11 @@ std::string Response::getFullURI(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DBOUT << "location" << _location->location << ENDL;
|
||||||
tmp = _request.getURI().substr(len);
|
tmp = _request.getURI().substr(len);
|
||||||
|
DBOUT << "tmp1 " << RED << tmp << ENDL;
|
||||||
tmp = _location->root + tmp;
|
tmp = _location->root + tmp;
|
||||||
|
DBOUT << "tmp2" << RED << tmp << ENDL;
|
||||||
}
|
}
|
||||||
if (_request.isDir(tmp) == 0)
|
if (_request.isDir(tmp) == 0)
|
||||||
{
|
{
|
||||||
@@ -320,11 +322,13 @@ void Response::generate2(serverListen &l)
|
|||||||
_fullURI = getFullURI();
|
_fullURI = getFullURI();
|
||||||
_method = _request.getMethod();
|
_method = _request.getMethod();
|
||||||
_maxBodySize = (_location->clientBodySize > 0) ? _location->clientBodySize : _config->getClientBodySize();
|
_maxBodySize = (_location->clientBodySize > 0) ? _location->clientBodySize : _config->getClientBodySize();
|
||||||
_code = (_request.getContentLength() > _maxBodySize) ? 413 : _code;
|
if (_maxBodySize > 0)
|
||||||
DBOUT << "max size" << _maxBodySize << ENDL;
|
_code = (_request.getRecved() > _maxBodySize) ? 413 : _code;
|
||||||
DBOUT << "_location size" << _location->clientBodySize << ENDL;
|
DBOUT << BLUE << "max size" << _maxBodySize << ENDL;
|
||||||
DBOUT << "_config sieze" << _config->getClientBodySize() << ENDL;
|
DBOUT << BLUE << "_location size" << _location->clientBodySize << ENDL;
|
||||||
DBOUT << "req size " << _request.getContentLength() << ENDL;
|
DBOUT << BLUE << "_config sieze" << _config->getClientBodySize() << ENDL;
|
||||||
|
DBOUT << BLUE << "req size " << _request.getContentLength() << ENDL;
|
||||||
|
DBOUT << BLUE << "recv size " << _request.getRecved() << ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBOUT << "fullURI " << _fullURI << ENDL;
|
DBOUT << "fullURI " << _fullURI << ENDL;
|
||||||
|
|||||||
Reference in New Issue
Block a user