is_cgi function is back and is working

+ in utils added function eval_file_mode(), it returns http errors codes about file
This commit is contained in:
Hugo LAMY
2022-08-14 01:05:20 +02:00
parent 285f2d049f
commit db4c7468cc
9 changed files with 100 additions and 35 deletions

View File

@@ -171,6 +171,21 @@ file_type eval_file_type(const std::string &path)
return (IS_OTHER);
}
size_t eval_file_mode(std::string path, int mode)
{
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)
{
std::perror("err access()");
return 403; // FORBIDDEN, file doesn't have execution permission
}
return 0;
}
void
replace_all_substr(