is_cgi function is back and is working

+ in utils added function eval_file_mode(), it returns http errors codes about file
This commit is contained in:
Hugo LAMY
2022-08-14 01:05:20 +02:00
parent 285f2d049f
commit db4c7468cc
9 changed files with 100 additions and 35 deletions

View File

@@ -202,26 +202,22 @@ void Client::parse_request_body()
status = 413; // HTTP Client Errors
}
// TODO HUGO : what if the root doesn't start with leading "." ?
void Client::fill_script_path(std::string &path, size_t pos)
{
std::string tmp;
// should start with "/"
// and being relative to the root :
// if the path to the script is "root/cgi-bin/cgi.php"
// the path relative to the root would be : /cgi-bin/cgi.php
// here we receive the path as : "./cgi-bin/cgi.php/optionnal"
// so we should remove the leading "."
/*DEBUG*/ std::cout << "\n" << B_PURPLE << "debug path dot" << RESET << "\npath:[" << path << "]\n" << "&path[pos]:[" << &path[pos] << "]\n";
if (path[0] == '.')
{
path.erase(0, 1);
pos--;
} /*DEBUG*/ std::cout << "path:[" << path << "]\n" << "&path[pos]:[" << &path[pos] << "]\n";
}
/*DEBUG*/ std::cout << "path:[" << path << "]\n" << "&path[pos]:[" << &path[pos] << "]\n";
_request.script.path = path.substr(0, pos); /*DEBUG*/ std::cout << "script_path:[" << _request.script.path << "]\n";
_request.script.info = path.substr(pos); /*DEBUG*/ std::cout << "script_info:[" << _request.script.info << "]\n" << B_PURPLE << "end debug path dot" << RESET << "\n";
_request.script.path = path.substr(0, pos);
/*DEBUG*/ std::cout << "script_path:[" << _request.script.path << "]\n";
_request.script.info = path.substr(pos);
/*DEBUG*/ std::cout << "script_info:[" << _request.script.info << "]\n" << B_PURPLE << "end debug path dot" << RESET << "\n";
}
void Client::clear()