mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
fix: linux tester
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
autoindex = true
|
||||
directory_file = "index.html"
|
||||
[[server.location]]
|
||||
location = "/put_test/*"
|
||||
location = "/put_test"
|
||||
root = "www/tester/"
|
||||
methods = ["PUT]"]
|
||||
methods = ["PUT"]
|
||||
autoindex = true
|
||||
upload_dir = "/www/tester/upload_here/"
|
||||
upload_dir = "www/tester/upload_here/"
|
||||
[[server.location]]
|
||||
location = "*.bla"
|
||||
cgi_pass = "~/.local/bin/cgi-test"
|
||||
@@ -23,7 +23,7 @@
|
||||
methods = ["POST"]
|
||||
body_size_limit = 100
|
||||
[[server.location]]
|
||||
location = "/directory/"
|
||||
location = "/directory"
|
||||
methods = ["GET"]
|
||||
root = "www/tester/YoupiBanane/"
|
||||
directory_file = "youpi.bad_extension"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ void Server::readSocket(Client &client, int fd)
|
||||
/* else if (bytes_read == -1) */
|
||||
/* throw std::logic_error("JOPA CLIENTU"); */
|
||||
// buf[bytes_read + 1] = '\0';
|
||||
DBOUT << stringBUF << ENDL;
|
||||
// DBOUT << stringBUF << ENDL;
|
||||
stringBUF.erase(bytes_read, stringBUF.size());
|
||||
/* DBOUT << "after erase" <<ENDL; */
|
||||
/* DBOUT << stringBUF << ENDL; */
|
||||
|
||||
Reference in New Issue
Block a user