diff --git a/config/default.conf b/config/default.conf index 9a7330b..79c9fea 100644 --- a/config/default.conf +++ b/config/default.conf @@ -48,7 +48,7 @@ server { allowed_methods GET; } - location /test { + location /test { root ./htdocs/site-1/tester; autoindex off; index index.html; @@ -128,7 +128,7 @@ server { listen 8083; host 127.0.0.1; server_name localhost; - client_max_body_size 1000m; + client_max_body_size 100m; root ./htdocs/YoupiBanane/; index index.html index2.htm; @@ -145,7 +145,7 @@ server { location /post_body { root ./htdocs/YoupiBanane/; - client_max_body_size 1000m; + client_max_body_size 100m; allowed_methods POST; } diff --git a/webserv/config/AConfig.cpp b/webserv/config/AConfig.cpp index 9546f4a..93c7e2a 100644 --- a/webserv/config/AConfig.cpp +++ b/webserv/config/AConfig.cpp @@ -42,6 +42,7 @@ void AConfig::addDirective(const std::string &line) std::string trimmedLine = utils::trim(line, " \n\r\t;"); // Reject unescaped quotes in directive values (quotes not supported by our parser) + //TODO should we support escaped quotes? if (trimmedLine.find('"') != std::string::npos) { throw std::runtime_error("Syntax error: unescaped quote in directive: " + trimmedLine); diff --git a/webserv/config/AConfig.hpp b/webserv/config/AConfig.hpp index 97d7798..f921af7 100644 --- a/webserv/config/AConfig.hpp +++ b/webserv/config/AConfig.hpp @@ -42,6 +42,7 @@ class AConfig } // Path resolution helpers + //TODO move to cpp file [[nodiscard]] std::string getBaseDir() const { return baseDir_; } void setBaseDir(const std::string &dir) { baseDir_ = dir; } diff --git a/webserv/config/ConfigManager.cpp b/webserv/config/ConfigManager.cpp index 0e22f57..826c37b 100644 --- a/webserv/config/ConfigManager.cpp +++ b/webserv/config/ConfigManager.cpp @@ -63,6 +63,8 @@ void ConfigManager::parseConfigFile(const std::string &filePath) } // Resolve base directory for relative paths based on the config file location std::filesystem::path p(filePath); + + //TODO should be cwd or should be global root? std::string baseDir = p.parent_path().string(); globalConfig_ = std::make_unique(baseDir, content); diff --git a/webserv/config/ServerConfig.cpp b/webserv/config/ServerConfig.cpp index 55e08b3..9e8e3e1 100644 --- a/webserv/config/ServerConfig.cpp +++ b/webserv/config/ServerConfig.cpp @@ -50,19 +50,7 @@ void ServerConfig::parseBlock(const std::string &block) if (locationPath.front() != '/') { - // Allow exact match syntax: "= /path" - if (locationPath.starts_with('=')) - { - std::string exactPath = utils::trim(locationPath.substr(1)); - if (exactPath.empty() || exactPath.front() != '/') - { - throw std::runtime_error("Exact match location path must start with '/': " + locationPath); - } - } - else - { - throw std::runtime_error("Location path must start with '/': " + locationPath); - } + throw std::runtime_error("Location path must start with '/': " + locationPath); } directives += block.substr(pos, locationPos - pos); diff --git a/webserv/config/validation/directive_rules/FolderExistsRule.cpp b/webserv/config/validation/directive_rules/FolderExistsRule.cpp index d46ed01..c839a55 100644 --- a/webserv/config/validation/directive_rules/FolderExistsRule.cpp +++ b/webserv/config/validation/directive_rules/FolderExistsRule.cpp @@ -24,6 +24,14 @@ ValidationResult FolderExistsRule::validateValue(const AConfig *config, const st auto folderPath = directive->getValue().get(); Log::debug("Validating folder exists: " + folderPath); + + // if (!FileUtils::isDirectory(folderPath)) + // { + // return ValidationResult::error(folderPath + " is not a valid directory"); + // } + + // TODO check if we change the basedir = cwd stuff if this is coreect? + // originally it just returns success when the previous tests didnt fail // Try multiple resolution strategies: // 1) As provided (relative to current working directory) // 2) Relative to config base directory diff --git a/webserv/config/validation/structural_rules/RequiredDirectivesRule.cpp b/webserv/config/validation/structural_rules/RequiredDirectivesRule.cpp index 7ef3bbf..47b8928 100644 --- a/webserv/config/validation/structural_rules/RequiredDirectivesRule.cpp +++ b/webserv/config/validation/structural_rules/RequiredDirectivesRule.cpp @@ -61,6 +61,8 @@ ValidationResult validateUniversal(const AConfig *config, std::string configType return ValidationResult::error(result); } +// TODO ! WTF is happening here, we should look at the hard coded validation rules again + ValidationResult RequiredDirectivesRule::validateGlobal(const GlobalConfig *config) const { // No globally required directives at this time; only prohibit invalid ones. @@ -85,6 +87,7 @@ ValidationResult RequiredDirectivesRule::validateGlobal(const GlobalConfig *conf ValidationResult RequiredDirectivesRule::validateServer(const ServerConfig *config) const { + // TODO missing directives are hard coded, it doesnt look at the table? // Only a minimal set is required for server blocks; other directives are optional. std::vector missing; if (!config->owns("listen")) diff --git a/webserv/handler/URI.cpp b/webserv/handler/URI.cpp index 3b25694..4de9b2b 100644 --- a/webserv/handler/URI.cpp +++ b/webserv/handler/URI.cpp @@ -36,6 +36,7 @@ const AConfig *URI::matchConfig(const std::string &uri, const ServerConfig &serv { return serverConfig.getLocation(locationPath); } + // TODO this matches only prefix, need to handle exact match if (uri.starts_with(utils::trim(locationPath, "/"))) { if (locationPath.length() > maxMatchLength) diff --git a/webserv/http/HttpHeaders.hpp b/webserv/http/HttpHeaders.hpp index 3b64a23..6a338db 100644 --- a/webserv/http/HttpHeaders.hpp +++ b/webserv/http/HttpHeaders.hpp @@ -19,6 +19,7 @@ class HttpHeaders { public: // Reasonable safety limits (aligned with common servers) + // TODO make configurable? or put in constants file? static constexpr size_t MAX_SINGLE_HEADER_SIZE = 8192; // 8KB per header value static constexpr size_t MAX_HEADER_COUNT = 64; // max number of distinct headers