more script tests

+ add cgi checks for error in script output
+ fix script_path relative to absolute
+ cgi makefile more efficient
This commit is contained in:
Hugo LAMY
2022-08-16 18:24:49 +02:00
parent ff443c80b1
commit 1ed4128afc
21 changed files with 485 additions and 109 deletions

View File

@@ -47,7 +47,7 @@ int Webserv::_send_response(Client *client)
if (client->status >= 400)
_error_html_response(client);
//*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output + headers]:" RESET "\n"; ::print_special(client->response); std::cout << "\n" B_PURPLE "-----------" RESET "\n\n";
/*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output + headers]:" RESET "\n"; ::print_special(client->response); std::cout << "\n" B_PURPLE "-----------" RESET "\n\n";
std::cerr << "client->response.size() = " << client->response.size() << "\n"; // DEBUG
ret = ::send(client->get_cl_fd(), client->response.c_str(), client->response.size(), 0);
@@ -86,16 +86,17 @@ void Webserv::_construct_response(Client *client)
std::string path;
std::string script_output;
/*DEBUG*/ std::cout << "\n" B_PURPLE "[responseeeeeeeeeeeeee]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
path = _replace_url_root(client, client->get_rq_abs_path());
if (_is_cgi(client, path))
{
script_output = _exec_cgi(client);
//*DEBUG*/ std::cout << "\n" B_PURPLE "[response]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
//*DEBUG*/ std::cout << "\n" B_PURPLE "[script output]:" RESET "\n"; ::print_special(script_output); std::cout << B_PURPLE "-----------" RESET "\n\n";
/*DEBUG*/ std::cout << "\n" B_PURPLE "[response]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
/*DEBUG*/ std::cout << "\n" B_PURPLE "[script output]:" RESET "\n"; ::print_special(script_output); std::cout << B_PURPLE "-----------" RESET "\n\n";
_check_script_output(client, script_output);
if (client->status < 400)
client->response += script_output;
//*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
/*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
return;
}