diff --git a/src/Server/ServerConfig.cpp b/src/Server/ServerConfig.cpp index 5b1d4dd..40da49f 100644 --- a/src/Server/ServerConfig.cpp +++ b/src/Server/ServerConfig.cpp @@ -3,12 +3,17 @@ ServerConfig::ServerConfig() { ret = 0; + _clientBodySize = 0; + _port = 0; } ServerConfig::ServerConfig(TOMLMap *map) { ret = 0; server = map; + _clientBodySize = 0; + _port = 0; + fillFields(); } @@ -133,6 +138,13 @@ int ServerConfig::putPort(toml_node *node) _port = node->getNum(); return (0); } + +void ServerConfig::resetLocation(location *tmp) +{ + tmp->autoindex = false; + tmp->uploadAccept = false; + tmp->clientBodySize = 0; +} int ServerConfig::putLocation(toml_node *node) { if (node->get_type() != toml_node::MAPARRAY) @@ -152,6 +164,7 @@ int ServerConfig::putLocation(toml_node *node) map = *it; it1 = map->begin(); tmp = new location; + resetLocation(tmp); while (it1 != map->end()) { if (it1->first == "location") @@ -190,6 +203,12 @@ int ServerConfig::putLocation(toml_node *node) return (1); tmp->cgi_pass = *it1->second->getString(); } + else if (it1->first == "body_size_limit") + { + if (node->get_type() != toml_node::NUM) + return (1); + tmp->clientBodySize = it1->second->getNum(); + } else if (it1->first == "directory_file") { if (it1->second->get_type() != toml_node::STRING) @@ -288,6 +307,7 @@ void ServerConfig::printFields(void) std::cout << YELLOW << "autoindex " << BLUE << (*it)->autoindex <uploadAccept <cgi_pass <clientBodySize <methods.begin(); while (it2 != (*it)->methods.end()) diff --git a/src/Server/ServerConfig.hpp b/src/Server/ServerConfig.hpp index 96365d2..748be9d 100644 --- a/src/Server/ServerConfig.hpp +++ b/src/Server/ServerConfig.hpp @@ -15,6 +15,7 @@ struct location std::vector methods; std::map redirect; std::string cgi_pass; + unsigned int clientBodySize; }; struct serverListen @@ -37,6 +38,7 @@ private: std::map _errorPages; std::vector _locations; + void resetLocation(location *); public: void setServerName(std::string); void setHost(std::string);