fix: added TODO's on what to work on
This commit is contained in:
parent
53eea8246b
commit
7115a7b907
@ -128,7 +128,7 @@ server {
|
|||||||
listen 8083;
|
listen 8083;
|
||||||
host 127.0.0.1;
|
host 127.0.0.1;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
client_max_body_size 1000m;
|
client_max_body_size 100m;
|
||||||
root ./htdocs/YoupiBanane/;
|
root ./htdocs/YoupiBanane/;
|
||||||
index index.html index2.htm;
|
index index.html index2.htm;
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ server {
|
|||||||
|
|
||||||
location /post_body {
|
location /post_body {
|
||||||
root ./htdocs/YoupiBanane/;
|
root ./htdocs/YoupiBanane/;
|
||||||
client_max_body_size 1000m;
|
client_max_body_size 100m;
|
||||||
allowed_methods POST;
|
allowed_methods POST;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ void AConfig::addDirective(const std::string &line)
|
|||||||
std::string trimmedLine = utils::trim(line, " \n\r\t;");
|
std::string trimmedLine = utils::trim(line, " \n\r\t;");
|
||||||
|
|
||||||
// Reject unescaped quotes in directive values (quotes not supported by our parser)
|
// Reject unescaped quotes in directive values (quotes not supported by our parser)
|
||||||
|
//TODO should we support escaped quotes?
|
||||||
if (trimmedLine.find('"') != std::string::npos)
|
if (trimmedLine.find('"') != std::string::npos)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Syntax error: unescaped quote in directive: " + trimmedLine);
|
throw std::runtime_error("Syntax error: unescaped quote in directive: " + trimmedLine);
|
||||||
|
|||||||
@ -42,6 +42,7 @@ class AConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Path resolution helpers
|
// Path resolution helpers
|
||||||
|
//TODO move to cpp file
|
||||||
[[nodiscard]] std::string getBaseDir() const { return baseDir_; }
|
[[nodiscard]] std::string getBaseDir() const { return baseDir_; }
|
||||||
|
|
||||||
void setBaseDir(const std::string &dir) { baseDir_ = dir; }
|
void setBaseDir(const std::string &dir) { baseDir_ = dir; }
|
||||||
|
|||||||
@ -63,6 +63,8 @@ void ConfigManager::parseConfigFile(const std::string &filePath)
|
|||||||
}
|
}
|
||||||
// Resolve base directory for relative paths based on the config file location
|
// Resolve base directory for relative paths based on the config file location
|
||||||
std::filesystem::path p(filePath);
|
std::filesystem::path p(filePath);
|
||||||
|
|
||||||
|
//TODO should be cwd or should be global root?
|
||||||
std::string baseDir = p.parent_path().string();
|
std::string baseDir = p.parent_path().string();
|
||||||
globalConfig_ = std::make_unique<GlobalConfig>(baseDir, content);
|
globalConfig_ = std::make_unique<GlobalConfig>(baseDir, content);
|
||||||
|
|
||||||
|
|||||||
@ -49,21 +49,9 @@ void ServerConfig::parseBlock(const std::string &block)
|
|||||||
// Add global declarations before this server block
|
// Add global declarations before this server block
|
||||||
|
|
||||||
if (locationPath.front() != '/')
|
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);
|
directives += block.substr(pos, locationPos - pos);
|
||||||
size_t closeBrace = utils::findCorrespondingClosingBrace(block, bracePos);
|
size_t closeBrace = utils::findCorrespondingClosingBrace(block, bracePos);
|
||||||
|
|||||||
@ -24,6 +24,14 @@ ValidationResult FolderExistsRule::validateValue(const AConfig *config, const st
|
|||||||
|
|
||||||
auto folderPath = directive->getValue().get<std::string>();
|
auto folderPath = directive->getValue().get<std::string>();
|
||||||
Log::debug("Validating folder exists: " + folderPath);
|
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:
|
// Try multiple resolution strategies:
|
||||||
// 1) As provided (relative to current working directory)
|
// 1) As provided (relative to current working directory)
|
||||||
// 2) Relative to config base directory
|
// 2) Relative to config base directory
|
||||||
|
|||||||
@ -61,6 +61,8 @@ ValidationResult validateUniversal(const AConfig *config, std::string configType
|
|||||||
return ValidationResult::error(result);
|
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
|
ValidationResult RequiredDirectivesRule::validateGlobal(const GlobalConfig *config) const
|
||||||
{
|
{
|
||||||
// No globally required directives at this time; only prohibit invalid ones.
|
// 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
|
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.
|
// Only a minimal set is required for server blocks; other directives are optional.
|
||||||
std::vector<std::string> missing;
|
std::vector<std::string> missing;
|
||||||
if (!config->owns("listen"))
|
if (!config->owns("listen"))
|
||||||
|
|||||||
@ -36,6 +36,7 @@ const AConfig *URI::matchConfig(const std::string &uri, const ServerConfig &serv
|
|||||||
{
|
{
|
||||||
return serverConfig.getLocation(locationPath);
|
return serverConfig.getLocation(locationPath);
|
||||||
}
|
}
|
||||||
|
// TODO this matches only prefix, need to handle exact match
|
||||||
if (uri.starts_with(utils::trim(locationPath, "/")))
|
if (uri.starts_with(utils::trim(locationPath, "/")))
|
||||||
{
|
{
|
||||||
if (locationPath.length() > maxMatchLength)
|
if (locationPath.length() > maxMatchLength)
|
||||||
|
|||||||
@ -19,6 +19,7 @@ class HttpHeaders
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Reasonable safety limits (aligned with common servers)
|
// 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_SINGLE_HEADER_SIZE = 8192; // 8KB per header value
|
||||||
static constexpr size_t MAX_HEADER_COUNT = 64; // max number of distinct headers
|
static constexpr size_t MAX_HEADER_COUNT = 64; // max number of distinct headers
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user