fixed mistake in _read_request()
+ changes to some log output
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
|
||||
std::string Webserv::_replace_url_root(Client *client, std::string path)
|
||||
{
|
||||
std::cerr << "path before = " << path << "\n"; // DEBUG
|
||||
std::cerr << "assigned_location->path = " << client->assigned_location->path << "\n"; // debug
|
||||
std::cerr << "path before = " << path << "\n"; // DEBUG
|
||||
if (client->assigned_location->path == "/")
|
||||
path.insert(0, client->assigned_location->root);
|
||||
else
|
||||
path.replace(0, client->assigned_location->path.size(), client->assigned_location->root);
|
||||
std::cerr << "path after = " << path << "\n"; // DEBUG
|
||||
std::cerr << "path after = " << path << "\n"; // DEBUG
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -20,7 +21,6 @@ void Webserv::_get(Client *client, std::string &path)
|
||||
// Index/Autoindex block
|
||||
if (eval_file_type(path) == IS_DIR)
|
||||
{
|
||||
std::cout << "made it to Index/Autoindex\n";
|
||||
if (path[path.size() - 1] != '/')
|
||||
path.push_back('/');
|
||||
for (size_t i = 0; i < client->assigned_location->index.size(); i++)
|
||||
@@ -50,7 +50,7 @@ void Webserv::_get_file(Client *client, const std::string &path)
|
||||
std::ifstream ifd; // For chunk, ifstream directly in struct CLient for multiples read without close() ?
|
||||
std::stringstream buf;
|
||||
|
||||
std::cout << "made it to get_file\n";
|
||||
std::cout << "_get_file()\n";
|
||||
|
||||
if (access(path.c_str(), F_OK) == -1)
|
||||
{
|
||||
@@ -103,16 +103,15 @@ void Webserv::_get_file(Client *client, const std::string &path)
|
||||
// const?
|
||||
void Webserv::_autoindex(Client *client, const std::string &path)
|
||||
{
|
||||
std::cout << "made it to _autoindex\n";
|
||||
std::cout << "_autoindex()\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 << "location root: " << client->assigned_location->root << " location path: " << client->assigned_location->path << '\n';
|
||||
|
||||
std::cout << "Path in auto is: " << path << '\n';
|
||||
// std::cout << "Path in auto is: " << path << '\n';
|
||||
if ( (dir = opendir(path.c_str()) ) != NULL)
|
||||
{
|
||||
dir_list.append(AUTOINDEX_START);
|
||||
@@ -123,7 +122,7 @@ 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=\"");
|
||||
|
||||
Reference in New Issue
Block a user