+ in fill_script_path() : scipt_path and script_info are filled, removing leadin dot

+ in _cgi_pos() : check validity of extension if it's only alpha characters
+ severall pbm appears
This commit is contained in:
hugogogo
2022-08-13 14:38:50 +02:00
parent defb2ada61
commit 285f2d049f
8 changed files with 60 additions and 43 deletions

View File

@@ -69,19 +69,20 @@ void Webserv::_append_base_headers(Client *client)
void Webserv::_construct_response(Client *client)
{
std::string path = _replace_url_root(client, client->get_rq_abs_path());
std::string path;
std::string script_output;
size_t pos = _cgi_pos(client, path); /*DEBUG*/ std::cout << "pos:" << pos << B_YELLOW << "\nfin debug _cgi_pos()\n\n" << RESET;
(void)pos;
path = _replace_url_root(client, client->get_rq_abs_path());
size_t pos = _cgi_pos(client, path); /*DEBUG*/ std::cout << "pos:" << pos << "\n&path[pos]:" << &path[pos] << "\n" << B_YELLOW << "fin debug _cgi_pos()\n\n" << RESET;
// if (pos != NPOS)
// {
// client->fill_script_path(path, pos);
// std::string script_output = _exec_cgi(client);
// _check_script_output(client, script_output);
// client->response += script_output;
// return;
// }
if (pos != NPOS)
{
client->fill_script_path(path, pos);
script_output = _exec_cgi(client);
_check_script_output(client, script_output);
client->response += script_output;
return;
}
_process_method(client, path);
}