diff --git a/srcs/sock/Client.cpp b/srcs/sock/Client.cpp index c346054..d6eeb33 100644 --- a/srcs/sock/Client.cpp +++ b/srcs/sock/Client.cpp @@ -67,12 +67,14 @@ bool Client::check_method(Server *server, Route *route, string method) { std::vector< string > allowed; if (method != "GET" && method != "POST" && method != "DELETE") send_error(405); - else if ((allowed = route->_headers).size() > 0) { - if (std::find(allowed.begin(), allowed.end(), method) == allowed.end()) - send_error(405); - } else if ((allowed = server->_headers).size() > 0) { - if (std::find(allowed.begin(), allowed.end(), method) == allowed.end()) - send_error(405); + else if ((allowed = route->_headers).size() > 0 && + std::find(allowed.begin(), allowed.end(), method) == + allowed.end()) { + send_error(405); + } else if ((allowed = server->_headers).size() > 0 && + std::find(allowed.begin(), allowed.end(), method) == + allowed.end()) { + send_error(405); } else return (true); return (false); diff --git a/srcs/webserv.cpp b/srcs/webserv.cpp index d6aa911..a6514d7 100644 --- a/srcs/webserv.cpp +++ b/srcs/webserv.cpp @@ -12,7 +12,7 @@ int main(int ac, char **av) { std::string config_file = "default.json"; if (ac == 2) config_file = av[1]; - std::ifstream file(config_file); + std::ifstream file(config_file.c_str()); if (!file.good()) throw std::runtime_error("File not found"); cout << "Parsing configuration file from JSON conf file.\n"; @@ -23,8 +23,7 @@ int main(int ac, char **av) { Env env(conf); while (1) env.cycle(); - } - catch(const std::exception& e) { + } catch (const std::exception &e) { std::cerr << e.what() << '\n'; } return EXIT_SUCCESS;