fixed an autoindex issue, working on uploading files

This commit is contained in:
Me
2022-08-12 23:45:13 +02:00
parent 4d395088d0
commit a69273b88e
6 changed files with 95 additions and 8 deletions

View File

@@ -105,11 +105,15 @@ void Webserv::_autoindex(Client *client, const std::string &path)
{
std::cout << "made it to _autoindex\n";
// std::cout << "client target: " << client->get_rq_target() << '\n';
std::string dir_list;
DIR *dir;
struct dirent *ent;
std::cout << "location root: " << client->assigned_location->root << " location path: "
// std::cout << "location root: " << client->assigned_location->root << " location path: "
<< client->assigned_location->path << '\n';
std::cout << "Path in auto is: " << path << '\n';
@@ -123,11 +127,13 @@ void Webserv::_autoindex(Client *client, const std::string &path)
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL)
{
std::cout << "ent: " << ent->d_name << '\n';
// std::cout << "ent: " << ent->d_name << '\n';
if (strcmp(".", ent->d_name) == 0)
continue ;
dir_list.append("<a href=\"");
dir_list.append(client->assigned_location->path + "/");
dir_list.append(client->get_rq_target());
if (dir_list[dir_list.size() - 1] != '/')
dir_list.push_back('/');
dir_list.append(ent->d_name);
dir_list.append("\">");
dir_list.append(ent->d_name);