wip integration of client.request and ServerConfig

+ Client get return reference
+ wip binary flags for http_method
+ moved config parser files
This commit is contained in:
LuckyLaszlo
2022-08-02 21:11:54 +02:00
parent 5aabeb6b46
commit 8f167d85f3
14 changed files with 107 additions and 70 deletions

View File

@@ -0,0 +1,85 @@
#include "ConfigParser.hpp"
void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
{
// make certain servers default
// fill out empty settings
// if special settings are empty throw
std::vector<ServerConfig>::iterator it = servers->begin();
while (it != servers->end())
{
// host and port should already be set
if (it->host == "")
throw std::invalid_argument("Config file needs a host and port");
// is that a good default?
if (it->root == "")
it->root = "/";
if (it->client_body_limit == 0)
it->client_body_limit = 5000; // what is the recomended size?
// autoindex should already be false by default right?
// what do we do if Allow methods is left empty?
// all ?
if (it->allow_methods.empty())
throw std::invalid_argument("No methods specified");
// what to do if index is left empty? index.html?
// ok but i still need to check index, no idea how...
// if error_pages is left empty, we'll use the defaults which
// i believe are set elsewhere...
std::vector<LocationConfig>::iterator it_l = it->locations.begin();
while (it_l != it->locations.end())
{
// check that path is feasible...
// opendir?
DIR* dir = opendir(it_l->path.c_str());
if (dir)
closedir(dir);
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?
if (it_l->root == "")
it_l->root = it->root;
// fill out allow methods from server?
if (it_l->allow_methods.empty())
it_l->allow_methods = it->allow_methods;
// fill out index from Server?
// or do a bunch of checks on what is in there...
// same for redirect status i think
// maybe do something for Cgi_info?
++it_l;
}
++it;
}
// do the defaults at the end?
}