From 0c13c023444ccf8eff35f679703730e36f4d69f4 Mon Sep 17 00:00:00 2001 From: 3lswear Date: Tue, 8 Feb 2022 22:08:52 +0300 Subject: [PATCH] misc --- config/real.toml | 40 ++++++++++++++++++++++++++++++++++++++++ src/Client/Response.cpp | 4 ++++ src/config/parse.cpp | 2 +- src/main.cpp | 2 +- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 config/real.toml diff --git a/config/real.toml b/config/real.toml new file mode 100644 index 0000000..bf5f769 --- /dev/null +++ b/config/real.toml @@ -0,0 +1,40 @@ +[[server]] + name = "pohek1.org" + host = "127.0.0.1" + port = 8080 + body_size_limit = 1000 + [server.error_page] + 404 = "error_404.html" + [[server.location]] + location = "/" + root = "www/" + redirect = ["301", "http://localhost/secret"] + methods = ["GET", "POST", "DELETE"] + autoindex = true + directory_file = "its_a_directory.html" + upload_accept = true + upload_dir = "/var/www/html/upload" + [[server.location]] + location = "/secret/" + root = "/var/www/html/secret.html" + methods = ["GET"] + autoindex = false + directory_file = "oops.html" +[[server]] + name = "pohek2.org" + host = "127.0.0.1" + port = 8081 + body_size_limit = 10000 + [server.error_page] + 404 = "error_404.html" + 405 = "error_405.html" + 406 = "error_406.html" + 407 = "error_407.html" + [[server.location]] + location = "/" + root = "www/" + methods = ["GET", "POST"] + autoindex = true + directory_file = "its_a_directory.html" + upload_accept = false + upload_dir = "/var/www/html/upload" diff --git a/src/Client/Response.cpp b/src/Client/Response.cpp index 2014773..1adfe52 100644 --- a/src/Client/Response.cpp +++ b/src/Client/Response.cpp @@ -236,6 +236,7 @@ void Response::generateBody(void) bool Response::allowedMethod(std::string &method) { + DBOUT << "allowedMethod called" << ENDL; std::vector::iterator it; it = _location->methods.begin(); @@ -290,8 +291,11 @@ void Response::generate2(void) _hostPort.ip = _config->getHost(); _hostPort.port = _config->getPort(); _fullURI = getFullURI(); + DBOUT << "fullURI " << _fullURI << ENDL; _method = _request.getMethod(); + DBOUT << RED << "code is " << _code << ENDL; + if (_request.badCode(_code) || !allowedMethod(_method)) { invalidClient(); diff --git a/src/config/parse.cpp b/src/config/parse.cpp index adab484..8e16c4d 100644 --- a/src/config/parse.cpp +++ b/src/config/parse.cpp @@ -40,7 +40,7 @@ namespace config TOMLMap *parse(void) { - std::string filename = "config/simple.toml"; + std::string filename = "config/real.toml"; config::TOMLParser parser(filename); TOMLMap *root = parser.parse(); /* config::display(root); */ diff --git a/src/main.cpp b/src/main.cpp index 7939772..84f3351 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) server.readConfig(); server.setupConfig(); server.start(); - // server.end(); + server.end(); return (0);