diff --git a/config/tester.toml b/config/tester.toml index 30f4cf8..2ab8615 100644 --- a/config/tester.toml +++ b/config/tester.toml @@ -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" diff --git a/src/Client/Request.cpp b/src/Client/Request.cpp index aedc783..37d0009 100644 --- a/src/Client/Request.cpp +++ b/src/Client/Request.cpp @@ -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; diff --git a/src/Client/Response.cpp b/src/Client/Response.cpp index 3afd70f..7b1ff22 100644 --- a/src/Client/Response.cpp +++ b/src/Client/Response.cpp @@ -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); diff --git a/src/Server/Server.cpp b/src/Server/Server.cpp index 2ca1231..5c608a7 100644 --- a/src/Server/Server.cpp +++ b/src/Server/Server.cpp @@ -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" <