CGI discussion and a little bit of work done

This commit is contained in:
LuckyLaszlo
2022-08-12 18:08:39 +02:00
parent cade79c37f
commit b44acafefe
9 changed files with 61 additions and 59 deletions

View File

@@ -69,22 +69,21 @@ void Webserv::_append_base_headers(Client *client)
void Webserv::_construct_response(Client *client)
{
/* Switch between normal behavior or CGI here ?
maybe better than in _get(), _post(), ...*/
std::string path = _replace_url_root(client, client->get_rq_abs_path());
std::string script_output;
if (_is_cgi(path))
/* size_t pos = _cgi_pos(client, path);
if (pos != NPOS)
{
script_output = _exec_cgi(client);
client->fill_script_path(path, pos);
std::string script_output = _exec_cgi(client);
_check_script_output(client, script_output);
client->response += script_output;
return;
}
_process_method(client);
} */
_process_method(client, path);
}
void Webserv::_process_method(Client *client)
void Webserv::_process_method(Client *client, std::string &path)
{
std::cerr << "assigned_location->path = " << client->assigned_location->path << "\n"; // debug
std::cerr << "allow_methods = " << client->assigned_location->allow_methods << "\n"; // debug
@@ -92,11 +91,11 @@ void Webserv::_process_method(Client *client)
switch (client->get_rq_method())
{
case (GET):
_get(client); break;
_get(client, path); break;
case (POST):
_post(client); break;
_post(client, path); break;
case (DELETE):
_delete(client); break;
_delete(client, path); break;
default:
break;
}