a few small fixes here and there, more telnet tests, starting Siege load testing

This commit is contained in:
Eric LAZO
2022-08-16 20:41:57 +02:00
parent ff443c80b1
commit 1b7d388231
17 changed files with 163 additions and 94 deletions

View File

@@ -19,6 +19,7 @@ void Webserv::_get(Client *client, std::string &path)
{
path.append(client->assigned_location->index[i]);
_get_file(client, path);
std::cerr << "Added an index\n"; //debug
return ;
}
}
@@ -88,16 +89,10 @@ void Webserv::_autoindex(Client *client, const std::string &path)
{
std::cout << "_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: " << client->assigned_location->path << '\n';
// std::cout << "Path in auto is: " << path << '\n';
if ( (dir = opendir(path.c_str()) ) != NULL)
{
@@ -106,20 +101,19 @@ void Webserv::_autoindex(Client *client, const std::string &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("<a style=\"font-size:1.5em\" href=\"");
// dir_list.append(client->get_rq_target());
dir_list.append(client->get_rq_abs_path());
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);
if (ent->d_type == DT_DIR)
dir_list.append("/");
dir_list.append("</a>");
dir_list.append("\n");
}
@@ -131,15 +125,14 @@ void Webserv::_autoindex(Client *client, const std::string &path)
// <a href="/test/test_deeper/..">..</a>
dir_list.append(AUTOINDEX_END);
// std::cout << "\n\n" << dir_list << '\n';
closedir (dir);
client->status = 200;
_append_body(client, dir_list, "html");
}
else
{
// in theory not possible cuz we already checked...
std::cerr << "could not open dir\n";
// throw?
client->status = 500;
perror("could not open dir");
return ;
}
}