Well we learned a lot from Nginx, starting to incorporate some, but hoping for feedback before i do most of that, instead worked on improving the location sorter and checking that locations paths are valid, close but not quite done
This commit is contained in:
@@ -3,47 +3,6 @@
|
||||
|
||||
#include "ConfigParser.hpp"
|
||||
|
||||
// technically doesn't belong to ConfigParser or any other class
|
||||
// adding static in front doesn't work...
|
||||
/*
|
||||
bool compareLocationConfigs(const LocationConfig &a, const LocationConfig &b)
|
||||
{
|
||||
int len_a;
|
||||
int len_b;
|
||||
size_t tmp = 0;
|
||||
|
||||
// consider adding 1 to path that ends in a file not folder.
|
||||
|
||||
|
||||
while ((tmp = a.path.find_first_of("/", tmp)) != std::string::npos)
|
||||
++len_a;
|
||||
tmp = 0;
|
||||
while ((tmp = b.path.find_first_of("/", tmp)) != std::string::npos)
|
||||
++len_b;
|
||||
return (len_a < len_b); // right comparison ? not <= ?
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
class spec_int
|
||||
{
|
||||
public:
|
||||
spec_int() {}
|
||||
spec_int(int i): i(i){}
|
||||
~spec_int() {}
|
||||
// spec_int(int start, int num)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
int i;
|
||||
bool operator<(const spec_int &a, const spec_int &b)
|
||||
{
|
||||
return (a.i < b.i);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
||||
{
|
||||
|
||||
@@ -83,7 +42,7 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
||||
|
||||
// actually do this at the end, once we know if there aren't any locations
|
||||
// with path /
|
||||
/* if (!_find_root_path_location(it->locations))
|
||||
if (!_find_root_path_location(it->locations))
|
||||
{
|
||||
LocationConfig tmp;
|
||||
|
||||
@@ -95,7 +54,7 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
||||
tmp.redirect_status = 0;
|
||||
it->locations.push_back(tmp);
|
||||
}
|
||||
*/
|
||||
|
||||
std::vector<LocationConfig>::iterator it_l = it->locations.begin();
|
||||
|
||||
// first check locations we have
|
||||
@@ -103,9 +62,11 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
||||
{
|
||||
// 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.c_str();
|
||||
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";
|
||||
@@ -114,7 +75,7 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
||||
}
|
||||
else
|
||||
throw std::invalid_argument("location dir could not be opened");
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user