ok Location sorting and processing is finally working as expected, still a few things to add like error_pages but will get there soon

This commit is contained in:
Me
2022-08-05 21:46:46 +02:00
parent 9ac14aa1aa
commit f7dc5ccde4
12 changed files with 119 additions and 114 deletions

View File

@@ -57,27 +57,8 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
std::vector<LocationConfig>::iterator it_l = it->locations.begin();
// first check locations we have
while (it_l != it->locations.end())
{
// opendir() doesn't work for some reason...
// this doens't work yet cuz the path needs to be relative and stat doesn't like / before...
const char* folder = it_l->path.substr(1).c_str();
struct stat sb;
// wait also have to add checks in for files!
// also need to add the root to the path!!!!!!!! see LocationConfig and parser
if (stat(folder, &sb) == 0 && S_ISDIR(sb.st_mode))
{
// std::cout << "is a Dir\n";
// it_l->path = it_lpath;
// yea nothing happens, i guess i can change how the if conditions work...
}
else
throw std::invalid_argument("location dir could not be opened");
if (it_l->client_body_limit == 0)
it_l->client_body_limit = 5000; // what is the recomended size?
@@ -97,26 +78,25 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
// maybe do something for Cgi_info?
// std::cout << "In Post, Root + Path: " << it_l->root + it_l->path << '\n';
if (path_is_valid(it_l->root + it_l->path) == 0)
{
//either we throw or we erase
throw std::invalid_argument("location path is invalid");
}
++it_l;
}
// ok we can sort in order and reverse...
std::cout << "made it to sorting...\n";
// std::cout << "made it to sorting...\n";
// std::sort(it->locations.begin(), it->locations.end(), compareLocationConfigs);
std::sort(it->locations.begin(), it->locations.end());
std::reverse(it->locations.begin(), it->locations.end());
++it;
}
// do the defaults at the end?
}
bool ConfigParser::_find_root_path_location(std::vector<LocationConfig> locations)