diff --git a/config.yml b/config.yml index 03d4065..34004ba 100644 --- a/config.yml +++ b/config.yml @@ -21,9 +21,9 @@ server: # * CGI extension exec. path map; cgi: .py: /usr/bin/python3 - .php: /usr/bin/php + # .php: /usr/bin/php # * Server routing; - route /main: # to do: HTTP redirect. + route /main: # to do: HTTP redirect. root: /pages index: index.html # default file to open if the request is the dir dir_listing: off @@ -32,7 +32,7 @@ server: root: /srcs/conn dir_listing: on http_methods: GET - #index: a.cpp Res.cpp Req1.cpp + index: a.cpp Res.cpp Req1.cpp route /up: root: /uploads dir_listing: on @@ -61,7 +61,7 @@ server: 400: error/400.html max_cbsize: 2000m max_conn: 5 - route /su: + route /s: root: /srcs dir_listing: on http_methods: GET diff --git a/srcs/__utils/__file_manager_utils.cpp b/srcs/__utils/__file_manager_utils.cpp index a297823..e1d3f13 100644 --- a/srcs/__utils/__file_manager_utils.cpp +++ b/srcs/__utils/__file_manager_utils.cpp @@ -72,11 +72,12 @@ std::string FileManager::directory_listing(const std::string path, std::string r DIR* dir = opendir(path.c_str()); std::stringstream ss; std::string entry_path; - if (!dir) throw HttpError("500", "Internal Server Error"); + if (route_path.size() == 0) + route_path = "/"; if (route_path[route_path.size() - 1] != '/') - route_path += "/"; + route_path += "/"; if (route_path[0] == '/') route_path.erase(0, 1); ss << ""; diff --git a/srcs/server_engine/ServerContext.cpp b/srcs/server_engine/ServerContext.cpp index 91675f9..eb00476 100644 --- a/srcs/server_engine/ServerContext.cpp +++ b/srcs/server_engine/ServerContext.cpp @@ -22,8 +22,10 @@ ServerContext::ServerContext(t_server serverNode) for (; cgi_it != serverNode.cgi.end(); cgi_it++) { - if (!fopen(cgi_it->second.c_str(), "r")) + FILE* file = fopen(cgi_it->second.c_str(), "r"); + if (!file) throw ServerError("CGI path doesn't exist. Maybe the cgi is not installed"); + fclose(file); this->cgi_path.insert(std::make_pair(cgi_it->first, cgi_it->second)); }