DELETE method tested and fixed

+ added 404 for directories without index and autoindex
+ minors adjustements
This commit is contained in:
LuckyLaszlo
2022-08-15 18:16:11 +02:00
parent a284e400c1
commit 3fe37ea451
7 changed files with 62 additions and 64 deletions

View File

@@ -171,18 +171,19 @@ file_type eval_file_type(const std::string &path)
return (IS_OTHER);
}
size_t eval_file_mode(std::string path, int mode)
// rename in "eval_file_access" ?
size_t eval_file_mode(const std::string &path, int mode)
{
if (access(path.c_str(), F_OK) == -1)
if (::access(path.c_str(), F_OK) == -1)
{
std::perror("err access()");
return 404; // NOT_FOUND, file doesn't exist
}
if (access(path.c_str(), mode) == -1)
if (::access(path.c_str(), mode) == -1)
{
std::perror("err access()");
return 403; // FORBIDDEN, file doesn't have execution permission
return 403; // FORBIDDEN, file doesn't have access permission
}
return 0;
}