diff --git a/srcs/webserv/method_get.cpp b/srcs/webserv/method_get.cpp index c6e3d08..72683f3 100644 --- a/srcs/webserv/method_get.cpp +++ b/srcs/webserv/method_get.cpp @@ -111,9 +111,6 @@ void Webserv::_get_file(Client *client, const std::string &path) } } -// i only sort of need &path... -// def can improve but works for now... -//void Webserv::_autoindex(Client *client, LocationConfig &location, std::string &path) void Webserv::_autoindex(Client *client, std::string &path) { std::cout << "made it to _autoindex\n"; @@ -122,24 +119,25 @@ void Webserv::_autoindex(Client *client, std::string &path) DIR *dir; struct dirent *ent; -// std::cout << "location root: " << client->assigned_location->root << " location path: " -// << client->assigned_location->path << '\n'; + std::cout << "location root: " << client->assigned_location->root << " location path: " + << client->assigned_location->path << '\n'; std::cout << "Path in auto is: " << path << '\n'; if ( (dir = opendir(path.c_str()) ) != NULL) { - /* print all the files and directories within directory */ dir_list.append(AUTOINDEX_START); dir_list.append(path); dir_list.append(AUTOINDEX_MID1); dir_list.append(path); dir_list.append(AUTOINDEX_MID2); + /* print all the files and directories within directory */ while ((ent = readdir (dir)) != NULL) { + std::cout << "ent: " << ent->d_name << '\n'; if (strcmp(".", ent->d_name) == 0) continue ; dir_list.append("assigned_location->path + "/"); dir_list.append(ent->d_name); dir_list.append("\">"); dir_list.append(ent->d_name); diff --git a/srcs/webserv/response.cpp b/srcs/webserv/response.cpp index 1ac1eff..fc5988b 100644 --- a/srcs/webserv/response.cpp +++ b/srcs/webserv/response.cpp @@ -209,6 +209,7 @@ If we get a url that ends in / ignore the last / return (&(*it)); else if (uri[it->path.size()] == '/') return (&(*it)); + // this works cuz only ever looking for a / burried in a longer path } } return (&(server.locations.back()));